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
#include <cstdio>
#include <stack>
using namespace std;

struct path {
    int a;
    int b;

    path(int a, int b): a(a), b(b) {}
};

int targets[100];
// n -> n+1 always
// if targets[n] != 0 then it's the second edge

stack<int> s;

int main() {
    int n;
    scanf("%d", &n);

    int c_idx = 1;
    int end = 99;
    
    while(n != 1){
        if (n % 2 == 1) {
            // prev operation was 0
            // next will be 0
            // so we can not move the idx
            n -= 1;
            targets[c_idx+1] = end;
        }
        if (n % 2 == 0) {
            n /= 2;
            targets[c_idx] = c_idx+2;
            c_idx+= 2;
        }
    }
    
    printf("99\n");
    for (int i = 1; i < 99; ++i){
        int second_target = -1;
        if (targets[i] != 0) {
            second_target = targets[i];
        }
        printf("%d %d\n", i+1, second_target);
    }
    printf("-1 -1\n");
}