407439: GYM102791 E Numbers on Whiteboard
Description
Numbers $$$1, 2, 3, \dots n$$$ (each integer from $$$1$$$ to $$$n$$$ once) are written on a board. In one operation you can erase any two numbers $$$a$$$ and $$$b$$$ from the board and write one integer $$$\frac{a + b}{2}$$$ rounded up instead.
You should perform the given operation $$$n - 1$$$ times and make the resulting number that will be left on the board as small as possible.
It's easy to see that after $$$n - 1$$$ operations, there will be left only one number. Your goal is to minimize it.
InputThe first line contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of integers written on the board initially.
OutputIn the first line, print the minimum possible number left on the board after $$$n - 1$$$ operations. Each of the next $$$n - 1$$$ lines should contain two integers — numbers $$$a$$$ and $$$b$$$ chosen and erased in each operation.
ExampleInput4Output
2 2 4 3 3 3 1Note
In the first sample, numbers $$$[1, 2, 3, 4]$$$ are written on the board initially. In the first operation, numbers $$$2$$$ and $$$4$$$ are erased and number $$$3$$$ are written instead. So, after the first operation, the numbers $$$[1, 3, 3]$$$ will be written. After the second operation, the numbers $$$[1, 3]$$$ will be written. Finally, after the third operation, the only number left is $$$2$$$.