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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair<int,int> pp;
vector<pp> v;
int ctr=1;
void solve(int k)
{
	if(k==1)	return;
	if(k&1)
	{
		v.pb(mp(0,ctr+1));
		++ctr;
		v.pb(mp(ctr+1,ctr+2));
		++ctr;
		v.pb(mp(ctr+1,-1));
		++ctr;
		solve(k>>1);
	}
	else
	{
		v.pb(mp(ctr+1,ctr+2));
		++ctr;
		v.pb(mp(ctr+1,-1));
		++ctr;
		solve(k>>1);
	}
}
int n;
int main()
{
	scanf("%d",&n);
	if(n==1)
	{
		//fajny edge case
		printf("2\n2 -1\n-1 -1\n");
		return 0;
	}
	solve(n);
	for(int i=0;i<v.size();++i)
	{
		if(!v[i].ff)	v[i].ff=v.size()+1;
		if(!v[i].ss)	v[i].ss=v.size()+1;
	}
	v.pb(mp(-1,-1));
	printf("%d\n",v.size());
	for(auto I : v)
	{
		printf("%d %d\n",I.ff,I.ss);
	}
}