1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include<bits/stdc++.h>
using namespace std;
vector<int> E[100];
int main(){
    int k=31;
    for(int i=1; i<k; i++){
        E[2*i-1].push_back(2*i);
        E[2*i-1].push_back(2*i+1);
        E[2*i].push_back(2*i+1);
    }
    int n;
    cin>>n;
    for(int i=1; n>0; i++,n/=2){
        if(n&1)E[2*i].push_back(2*k);
    }
    cout<<2*k<<"\n";
    for(int i=1; i<=2*k; i++){
        while(E[i].size()<2)E[i].push_back(-1);
        cout<<E[i][0]<<" "<<E[i][1]<<"\n";
    }
}