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
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REPD(i,n) FORD(i,0,n)
#define VAR(v,w) __typeof(w) v=(w)
#define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it)
#define PB push_back
#define ALL(c) (c).begin(),(c).end()
#define SIZE(c) ((int)(c).size())
#define MP make_pair
#define FT first
#define SD second
#define INT(x) int x; scanf("%d", &x)

typedef pair<int,int> PII;
typedef vector<PII> VII;

int main() {
	INT(k);
	int n = 0;
	int kk = k;
	while (kk > 1) {
		kk >>= 1;
		++n;
	}
	VII v;
	v.PB(MP(-1, -1));
	v.PB(MP(0, -1));
	REPD(i,n) {
		v.PB(MP(SIZE(v) - 1, -!(k & (1 << i))));
		v.PB(MP(SIZE(v) - 2, SIZE(v) - 1));
	}
	reverse(ALL(v));
	FORE(it,v) {
		if (it->FT >= 0) it->FT = SIZE(v) - it->FT;
		if (it->SD >= 0) it->SD = SIZE(v) - it->SD;
	}
	printf("%d\n", SIZE(v));
	FORE(it,v) printf("%d %d\n", it->FT, it->SD);
}