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

#define Z 18
#define B 11
int buckets[B];

int c;

#define SKIP_WHITESPACE \
{   \
    while (1) { \
        c = fgetc(stdin);   \
        if (c != ' ' && c != '\n' && c != '\r') \
            break;  \
    }   \
}   \

#define READ_INT    \
({   \
    SKIP_WHITESPACE \
    int ret = c - '0';  \
    while (1) { \
        c = fgetc(stdin);   \
        if (c < '0' || c > '9') \
            break;  \
        ret = ret * 10 + c - '0';   \
    }   \
    ret; \
})   \

int main(int argc, char* argv[]) {
    std::ios_base::sync_with_stdio (false);

    int i, x, a = 0, b = 0;
    for (i = 0; i < Z; ++i) {
        x = READ_INT;
        a += x;
        buckets[x]--;
    }
    for (i = 0; i < Z; ++i) {
        x = READ_INT;
        b += x;
        buckets[x]++;
    }

    int res = 0;
    do {
        if (a > b) {
            res = -1;
            break;
        } else if (a < b) {
            res = 1;
            break;
        }
        for (i = B; i > 0; --i) {
            if (buckets[i]) {
                res = buckets[i];
                break;
            }
        }
    } while(0);

    if (res < 0) {
        std::cout << "Algosia";
    } else if (res > 0) {
        std::cout << "Bajtek";
    } else {
        std::cout << "remis";
    }
    return EXIT_SUCCESS;
}