{"problem":{"name":"Snuke's Coloring 2","description":{"content":"There is a rectangle in the $xy$\\-plane, with its lower left corner at $(0, 0)$ and its upper right corner at $(W, H)$. Each of its sides is parallel to the $x$\\-axis or $y$\\-axis. Initially, the whol","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc063_d"},"statements":[{"statement_type":"Markdown","content":"There is a rectangle in the $xy$\\-plane, with its lower left corner at $(0, 0)$ and its upper right corner at $(W, H)$. Each of its sides is parallel to the $x$\\-axis or $y$\\-axis. Initially, the whole region within the rectangle is painted white.\nSnuke plotted $N$ points into the rectangle. The coordinate of the $i$\\-th ($1 ≦ i ≦ N$) point was $(x_i, y_i)$.\nThen, for each $1 ≦ i ≦ N$, he will paint one of the following four regions black:\n\n*   the region satisfying $x < x_i$ within the rectangle\n*   the region satisfying $x > x_i$ within the rectangle\n*   the region satisfying $y < y_i$ within the rectangle\n*   the region satisfying $y > y_i$ within the rectangle\n\nFind the longest possible perimeter of the white region of a rectangular shape within the rectangle after he finishes painting.\n\n## Constraints\n\n*   $1 ≦ W, H ≦ 10^8$\n*   $1 ≦ N ≦ 3 \\times 10^5$\n*   $0 ≦ x_i ≦ W$ ($1 ≦ i ≦ N$)\n*   $0 ≦ y_i ≦ H$ ($1 ≦ i ≦ N$)\n*   $W$, $H$ (21:32, added), $x_i$ and $y_i$ are integers.\n*   If $i ≠ j$, then $x_i ≠ x_j$ and $y_i ≠ y_j$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$W$ $H$ $N$\n$x_1$ $y_1$\n$x_2$ $y_2$\n$:$\n$x_N$ $y_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc063_d","tags":[],"sample_group":[["10 10 4\n1 6\n4 1\n6 9\n9 4","32\n\nIn this case, the maximum perimeter of $32$ can be obtained by painting the rectangle as follows:\n\n![image](https://atcoder.jp/img/arc063/842bb3939c9721d978d4e122b0bfff55.png)"],["5 4 5\n0 0\n1 1\n2 2\n4 3\n5 4","12"],["100 100 8\n19 33\n8 10\n52 18\n94 2\n81 36\n88 95\n67 83\n20 71","270"],["100000000 100000000 1\n3 4","399999994"]],"created_at":"2026-03-03 11:01:14"}}