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
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>

using namespace std;
int T[100];
vector<int> T2;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin>>k;
    int i=1;
    int pop= 1;
    int pom;
   int  n=2;
   //T[0]
   T[1]=1;
   T[2]=1;
    while(i<=k){
        pom =i;
        i = i +pop;
        pop = pom;
        //cout<<i<<"\n";
        n++;
        T[n]=i;
    }
    n--;
    int dod = k-T[n];
    //cout<<n<<" "<<dod<<"\n";
    int sum = 0;
    for(int j=n;j>=1;j--){
        if(sum+T[j]<=dod){
            sum = sum+T[j];
            //cout<<"d"<<T[j]<<"\n";
            T2.push_back(T[j]);
        }
    }
   // cout<<dod<<" "<<sum<<"\n";
    cout<<n+T2.size()<<"\n";
    i = 1;
    int l = T2.size()-1;
    //cout<<T2.size()<<endl;
    for(int k=1;k<=n+T2.size()-2;k++){
        if(l>=0 and T[i] == T2[l]){
            cout<<n+T2.size()<<" "<<k+1<<"\n";
            l--;
        }
        else if(l>=0 and T[i+1] ==T2[l]) {
        cout<<k+1<<" "<<k+3<<"\n";
        i++;
        }
        else{
            cout<<k+1<<" "<<k+2<<"\n";
            i++;
        }
    }
    cout<<n+T2.size()<<" "<<-1<<"\n";
    cout<<-1<<" "<<-1<<"\n";
}