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

int n;
vector<int> powersIds;

int main(){
	ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cout.tie( 0 );
	cin>>n;
	int size = 2*(int)log2(n)+2;
	cout<<size<<endl;
	for (int i = 1; i < size; i++){
		if( i % 2 == 1 ){
			if( i == size - 1 ){
				cout<<size<<" -1"<<endl;
			} else {
				cout<<i+2<<" "<<i+1<<endl;
			}
		} else {
			if( (n & ( 1 << ( ( i / 2 ) - 1 ) ) ) > 0){
				cout<<i+1<<" "<<size<<endl;
			} else {
				cout<<i+1<<" -1"<<endl;			
			}
		}
	}
	cout<<"-1 -1";
	return 0;
}