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

#define pb push_back
#define st first
#define nd second

using ll = long long;
using ld = long double;

using namespace std;

int algosia_wiecej[15], a, b;

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

    for(int i = 0; i < 18; i++) {
        int x;
        cin >> x;
        a += x;
        algosia_wiecej[x]++;
    }
    for(int i = 0; i < 18; i++) {
        int x; 
        cin >> x;
        b += x;
        algosia_wiecej[x]--;
    }
    if(a > b) 
        cout << "Algosia";
    else if(b > a)
        cout << "Bajtek";
    else {
        int x = 10;
        while(x >= 0 && algosia_wiecej[x] == 0) {
            x--;
        }
        if(x != -1) {
            if(algosia_wiecej[x] > 0)
                cout << "Algosia";
            else
                cout << "Bajtek";
        }
        else {
            cout << "remis";
        }
    }

    return 0;
}