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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long double db;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    const int n = 18, m = 10;
    VI sum(2);
    vector a(2, VI(m + 1));
    FOR(i, 0, 2)
    {
        FOR(j, 0, n)
        {
            int x;
            cin >> x;
            sum[i] += x;
            a[i][x]++;
        }
        reverse(ALL(a[i]));
    }
    pair<int, VI> p0 = MP(sum[0], a[0]);
    pair<int, VI> p1 = MP(sum[1], a[1]);
    if (p0 > p1)
    {
        cout << "Algosia\n";
    }
    else if (p1 > p0)
    {
        cout << "Bajtek\n";
    }
    else
    {
        cout << "remis\n";
    }
	return 0;
}