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
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <bitset>

using namespace std;
typedef long long int lli;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    lli n;
    cin >> n;
    int v = ((int) log2(n) + 1) * 2;
    auto bits = bitset<32>(n);
    vector<pair<int, int>> verts(v);
    verts[v-2] = {v, -1};
    verts[v-1] = {-1, -1};
    for (int i = 0; i < v-2; i++) {
        if (i % 2 == 0) {
            verts[i] = {i+2, i+3};
        } else {
            verts[i] = {i+2, bits[i / 2] ? v : -1};
        }
    }
    cout << v << '\n';
    for (pair<int, int> vert : verts) {
        cout << vert.first << " " << vert.second << '\n';
    }
    return 0;
}