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;

using ll = long long;
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define loop_rev(i, a, b) for(int i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pb push_back

using ull = unsigned long long;
using uint = unsigned int;
int tab1[20], tab2[20];
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int res1 = 0, res2 = 0;
    loop(i, 1, 18) {
        int a; 
        cin >> a;
        tab1[a]++;
        res1 += a;
    }
    loop(i, 1, 18) {
        int a;
        cin>>a;
        tab2[a]++;
        res2 += a;
    } 
    if(res1 > res2){
        cout<<"Algosia";
        return 0;
    }
    if(res1 < res2){
        cout<<"Bajtek";
        return 0;
    }
    if(res1 == res2) {
        loop_rev(i, 10, 0) { 
            if(tab1[i] == tab2[i]) continue;
            if(tab1[i] > tab2[i]) {
                cout<<"Algosia";
                return 0;
            }
            else {
                cout<<"Bajtek";
                return 0;
            }
        }
    }
    cout<<"remis";
}