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

vector<int>L;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int N = 0;
    while(n>0){
        if(n%2){
            L.push_back(1);
            n--;
            N++;
        }else{
            L.push_back(0);
            n/=2;
            N+=2;

        }
    }
    N++;
    cout<<N<<"\n";
    int V = 1;
    for(int i =0;i<L.size();i++){
        if(L[i]==1){
            if(V+1 == N){
                cout<<V+1<<" "<<-1<<"\n";
            }else{
                cout<<V+1<<" "<<N<<"\n";
            }
            V++;
        }else{
            cout<<V+1<<" "<<V+2<<"\n"; 
            cout<<V+2<<" "<<-1<<"\n";
            V+=2;
        }
    }
    cout<<-1<<" "<<-1<<"\n";

    return 0;
}