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
55
#include <bits/stdc++.h>

using namespace std;

int powers[105];
pair<int,int> kr[105];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int k;
	cin >> k;
	if(k == 1){
		cout << 2 << '\n';
		cout << -1 << ' ' << 2 << '\n';
		cout << -1 << ' ' << -1 << '\n';
		return 0;
	}
	int pot = 1;
	int wykl = 0;
	int v = 100;
	pot = 1;
	kr[v] = {-1,-1};
	powers[0] = v;
	while(pot * 2 <= k){
		wykl++;
		pot *= 2;
		v--;
		kr[v] = {-1,v+1};
		v--;
		kr[v] = {v+1,v+2};
		powers[wykl] = v;
	}
	int cnt = pot;
	while(cnt < k){
		v--;
		while(pot + cnt > k){
			wykl--;
			pot /= 2;
		}
		kr[v] = {v+1,powers[wykl]};
		cnt += pot;
	}
	cout << 100 - v + 1 << '\n';
	int t = v - 1;
	for(int i = v; i <= 100; i++){
		int x = kr[i].first;
		int y = kr[i].second;
		if(x != -1)
			x -= t;
		if(y != -1)
			y -= t;
		cout << x << ' ' << y << '\n';
	}
	return 0;
}