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

struct score {
        std::vector<int> p;

        score(void) : p(10 + 1, 0) {}
        int sum(void) const {
                return std::accumulate(p.begin(), p.end(), 0, std::plus<int>{});
        }
        bool operator<(const score &that) const {
                if (this->sum() < that.sum())
                        return true;
                for (int i = 10; i > 0; i--)
                        if (this->p[i] < that.p[i])
                                return true;
                return false;
        }
};

int main() {
        score algosia{}, bajtek{};
        for (int i = 0; i < 18; i++) {
                int n;
                std::cin >> n;
                algosia.p[n]++;
        }
        for (int i = 0; i < 18; i++) {
                int n;
                std::cin >> n;
                bajtek.p[n]++;
        }
        if (bajtek < algosia)
                std::cout << "Algosia\n";
        else if (algosia < bajtek)
                std::cout << "Bajtek\n";
        else
                std::cout << "remis\n";
}