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

using namespace std;

void solve() {
    int k;
    cin >> k;
    bool was = false;
    int cnt = 1;
    vector<pair<int, int> > v;
    v.push_back({-1, -1});
    v.push_back({0, -1});
    for (int i = 31; i >= 0; i--) {
        if (was) {
            if ((k>>i)&1) {
                v.push_back({cnt, 0});
            } else {
                v.push_back({cnt, -1});
            }
            v.push_back({cnt + 1, cnt});
            cnt += 2;
        }
        if ((k>>i)&1) {
            was = true;
        }
    }
    int n = cnt+1;
    auto convert = [&](int x) {
        if (x == -1) return -1;
        return n - x;
    };
    cout << n << "\n";
    for (int i = v.size() - 1; i >= 0; i--) {
        int x = v[i].first;
        int y = v[i].second;
        cout << convert(v[i].first) << " " << convert(v[i].second) << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(15);
    cout << fixed;
    cin.tie(0);

    int T = 1;
    //cin >> T;
    for (int tst = 0; tst < T; tst++) {
        solve();
    }

    return 0;
}