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
#include <iostream>

#include <cstddef>

using namespace std;

using Num = long long;

using Usize = size_t;

struct Summary {
    static Usize constexpr ROUNDS { 18 };
    static Num constexpr MAX_SCORE { 10 };

    Num total { 0 };
    Num scores[MAX_SCORE + 1] {};
};

istream& operator>>(istream& in, Summary& summary) {
    for(Usize _ { 0 }; _ < Summary::ROUNDS; _++) {
        Num score;
        in >> score;
        summary.total += score;
        summary.scores[score]++;
    }
    return in;
}

bool operator<(Summary const& lhs, Summary const& rhs) {
    if(lhs.total != rhs.total)
        return lhs.total < rhs.total;
    for(Num score { Summary::MAX_SCORE }; score >= 0; score--)
        if(lhs.scores[score] != rhs.scores[score])
            return lhs.scores[score] < rhs.scores[score];
    return false;
}

void solve() {
    Summary summary_a, summary_b;
    cin >> summary_a >> summary_b;
    if(summary_a < summary_b)
        cout << "Bajtek";
    else if(summary_b < summary_a)
        cout << "Algosia";
    else
        cout << "remis";
    cout << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}