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
57
58
#include <iostream>
using namespace std;


struct scores {
    int s[11];
    int total;

    scores() {
        total = 0;
        for (int i = 0; i <= 10; ++i) {
            s[i] = 0;
        }
    }

	void add_score(int x) {
		s[x]++;
		total += x;
	}
};

bool operator<(const scores& a, const scores& b) {
    if (a.total != b.total)
        return (a.total < b.total);

    for (int i = 10; i > 0; --i) {
        if (a.s[i] != b.s[i])
            return (a.s[i] < b.s[i]);
    }

    return false;
}

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

	scores ab[2];

	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 18; ++j) {
			int x;
			cin >> x;

			ab[i].add_score(x);
		}
	}

	bool algosia = (ab[1] < ab[0]);
	bool bajtek = (ab[0] < ab[1]);

	if (!algosia && !bajtek)
		cout << "remis" << endl;
	else if (algosia)
		cout << "Algosia" << endl;
	else
		cout << "Bajtek" << endl;
}