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
#include <bits/stdc++.h>
using namespace std;
int k, kt_pot;
long long pot=1;
bool hop[35];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>k;
    if(k==1)
    {
        cout<<"2\n2 -1\n-1 -1\n";
        return 0;
    }
    while(pot*2<=k){pot*=2;++kt_pot;}
    int i=kt_pot;
    while(pot)
    {
        if(pot<=k)
        {
            hop[i]=true;
            k-=pot;
        }
        pot/=2;
        --i;
    }
    cout<<kt_pot*3+3<<"\n";
    if(hop[0])cout<<"2 "<<kt_pot*3+2<<"\n";
    else cout<<"2 -1\n";
    for(int i=1; i<=kt_pot; ++i)
    {
        cout<<i*3<<" "<<i*3+1<<"\n";
        cout<<i*3+1<<" -1\n";
        cout<<i*3+2<<" ";
        if(hop[i]&&i<kt_pot)cout<<kt_pot*3+2<<"\n";
        else cout<<"-1\n";
    }
    cout<<kt_pot*3+3<<" -1\n";
    cout<<"-1 -1\n";
}