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
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, l, r) for (auto i = (l); i <= (r); ++i)
#define REP(i, n) FOR (i, 0, (n)-1)

int
main()
{
    cin.tie(0)->sync_with_stdio(0);
    int Asum = 0, Bsum = 0, x;
    vector<int> Acnt(11), Bcnt(11);

    REP (i, 18) {
        cin >> x;
        Asum += x;
        Acnt[x]++;
    }
    REP (i, 18) {
        cin >> x;
        Bsum += x;
        Bcnt[x]++;
    }

    if (Asum > Bsum) goto awin;
    if (Bsum > Asum) goto bwin;

    for (int i = 10; i > 0; --i) {
        if (Acnt[i] > Bcnt[i]) goto awin;
        if (Acnt[i] < Bcnt[i]) goto bwin;
    }
    cout << "remis\n";
    return 0;

awin:
    cout << "Algosia\n";
    return 0;
bwin:
    cout << "Bajtek\n";
    return 0;
}