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

using namespace std; ///

vector<int> get() {
    vector<int> a;
    for (int i = 0; i < 18; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int sum = 0;
    for (const auto& x : a) sum += x;
    vector<int> b(12, 0);
    b[11] = sum;
    for (const auto& x : a) ++b[x];
    reverse(b.begin(), b.end());
    return b;
}

int main() {
    ios_base::sync_with_stdio(false);
    vector<int> a = get(), b = get();
    if (a > b) cout << "Algosia" << endl; else
    if (a < b) cout << "Bajtek" << endl; else cout << "remis" << endl;
    return 0;
}