1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
#define ff first
#define ss second
const int N=100;

using namespace std;

int n,l;
pair <int,int> g[N];

int main() {
	scanf("%d",&n);
	l=31-__builtin_clz(n);

	for (int i=0; i<l; i++) {
		g[2*i] = {2*i+1,2*i+2};
		g[2*i+1]={2*i+2,-2};
	}
	g[2*l]={2*l+1,-2};
	g[2*l+1]={-2,-2};

	for (int i=0; i<l; i++) {
		if (n&1) {
			g[2*i+1].ss=2*l+1;
		}
		n/=2;
	}

	printf("%d\n",2*l+2);
	for (int i=0; i<2*l+2; i++) {
		printf("%d %d\n",g[i].ff+1,g[i].ss+1);
	}
	return 0;
}