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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " " << x << endl;

// #define int long long // uważaj

const int N = 5005;
const int n = 100;
int t[N][2];

void solve() {
    int k;
    cin >> k;

    for(int i = 1; i <= n; i++) {
        t[i][0] = t[i][1] = -1;
    }

    for(int i = 1; i < 16; i++) {
        t[i][0] = 2 * i;
        t[i][1] = 2 * i + 1;
    }

    t[32][0] = 100;
    t[33][0] = 100;

    int ile = 2;
    vector<int> pot;
    pot.push_back(32);

    int a = 34;
    int b = 35;
    while(ile <= (1000) * (1000) * (1000)) {
        // debug(a);
        // debug(b);
        t[a][0] = a - 2;
        t[a][1] = b - 2;

        t[b][0] = a - 2;
        t[b][1] = b - 2;

        pot.push_back(a);
        ile *= 2;
        a += 2;
        b += 2;
    }

    vector<pair<int, int> > wolne;
    for(int i = 16; i <= 31; i++) {
        wolne.push_back(make_pair(i, 0));
        wolne.push_back(make_pair(i, 1));
    }

    ile = 1;
    int krok = 0;

    while(ile <= (1000) * (1000) * (1000)) {
        if(ile & k) {
            // debug(ile);
            pair<int, int> a = wolne.back();
            wolne.pop_back();
            t[a.first][a.second] = pot[krok];
        }
        krok ++;
        ile *= 2;
    }

    cout << n << "\n";
    for(int i = 1; i <= n; i++) {
        // debug(i);
        cout << t[i][0] << " " << t[i][1] << "\n";
    }
}

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int test = 1;

	while(test--) {
		solve();
	}

	return 0;
}