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
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int n;
    scanf("%i\n", &n);
    char buf[9];
    char* ptr;
    unsigned ones = 0;
    while (ptr = fgets(buf, 9, stdin)) {
        for (unsigned x = 0; x < 8; x++)
            if (buf[x] == '1') ++ones;
            else if (buf[x] != '0') break;
    }

    long extra = ones - n * 3;
    if (extra < 0 || extra > n * 3)
        puts("NIE");
    else
    {
        while (extra >= 3) {
            putchar('o');
            extra -= 3;
            n--;
        }
        while (extra >= 2) {
            putchar('k');
            extra -= 2;
            n--;
        }
        while (extra >= 1) {
            putchar('c');
            extra -= 1;
            n--;
        }
        while (n > 0) {
            putchar('a');
            n--;
        }
    }
    putchar('\n');
    return 0;
}