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
#include <stdio.h>

const int B = 32; // Musi być potęgą dwójki
const int N = 3 * B;

int main()
{
    int left[N+1];
    int right[N+1];
    
    for (int i = 1; i < B; i++)
    {
        left[i] = 2 * i;
        right[i] = 2 * i + 1;
    }
    
    for (int i = B; i < 2 * B - 1; i++)
    {
        left[i] = i + 1;
        right[i] = i + 1 + B;
    }
    
    left[2 * B - 1] = 3 * B;
    right[2 * B - 1] = -1;
    
    for (int i = 2 * B; i < 3 * B - 1; i++)
    {
        left[i] = i + 1;
        right[i] = i + 1 - B;
    }
    
    left[3 * B - 1] = 3 * B;
    right[3 * B - 1] = -1;
    
    left[3 * B] = -1;
    right[3 * B] = -1;
    
    int k;
    scanf("%d", &k);
    for (int i = 1; i <= B / 2; i++)
    {
        if (k % 2 == 0)
            right[B - i] = -1;
        k /= 2;
        
        if (k % 2 == 0)
            left[B - i] = -1;
        k /= 2;
    }
    
    printf("%d\n", N);
    for (int i = 1; i <= N; i++)
        printf("%d %d\n", left[i], right[i]);
    
    return 0;
}