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
// Author: Bartek Knapik

#include <cstdio>

int counts[11][2];

int solve()
{
    int sa, sb;
    sa = sb = 0;
    for (int i = 1; i <= 10; ++i)
    {
        sa += i * counts[i][0];
        sb += i * counts[i][1];
    }
    
    if (sa != sb) return sa < sb ? 1 : -1;
    
    for (int i = 10; i > 0; --i)
        if (counts[i][0] != counts[i][1]) return counts[i][0] < counts[i][1] ? 1 : -1;

    return 0;
}

int main()
{
    int tmp, ans;
    for (int i = 0; i < 18; ++i)
    {
        scanf("%d", &tmp);
        counts[tmp][0]++;
    }
    for (int i = 0; i < 18; ++i)
    {
        scanf("%d", &tmp);
        counts[tmp][1]++;
    }
    ans = solve();
    if (ans == -1) printf("Algosia\n");
    else if (ans == 1) printf("Bajtek\n");
    else printf("remis\n");
}