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
#include<bits/stdc++.h>

using namespace std;

int f(const vector<int> &A, const vector<int> &B, int sa, int sb)
{
    if(sa != sb) return sa - sb;
    for(int i=10; i>=0; i--)
    {
        if(A[i] != B[i]) return A[i] - B[i];
    }

    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector<int> A(11), B(11);
    int sa = 0, sb = 0;

    for(int i=0; i<18; i++)
    {
        int x;
        cin >> x;
        sa += x;
        A[x]++;
    }

    for(int i=0; i<18; i++)
    {
        int x;
        cin >> x;
        sb += x;
        B[x]++;
    }

    int r = f(A, B, sa, sb);
    if(r > 0) cout << "Algosia" << "\n";
    else if(r < 0) cout << "Bajtek" << "\n";
    else cout << "remis" << "\n";
}