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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <bits/stdc++.h>
using namespace std;

int n = 100, k, l;
set <pair <int, int> > s;
vector <int> gr[10001];

void bgr()
{
    for(int i = 1; i < 100; i++)
        gr[i].push_back(i + 1);

    s.insert({1, 100});

    int av = 98, cap = 1;

    while(cap < k)
    {
        set <pair <int, int> >::iterator it = s.lower_bound({k - cap, 101});

        it--;

        if((*it).second == av + 1)
        {
            set <pair <int, int> >::iterator tym = it;

            tym++;

            if(tym != s.end())
            {
                it++;

                if((*it).first > k - cap)
                {
                    it--;

                    if(it != s.begin())
                        it--;
                    else
                        av--;
                }
            }
            else if(it != s.begin())
                it--;
            else
                av--;
        }

        cap += (*it).first;

        gr[av].push_back((*it).second);

        s.insert({cap, av});

        av--;
    }
}

int main()
{
    scanf("%d", &k);

    bgr();

    printf("100\n");

    for(int v = 1; v <= 100; v++)
    {
        for(auto& u : gr[v])
            printf("%d ", min(u, n));
        for(int i = 2; i > gr[v].size(); i--)
            printf("-1 ");
        printf("\n");
    }
}