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
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int tab[2][18];

    // Read numbers into the array
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 18; j++) {
            cin >> tab[i][j];
        }
    }

    // Sort the array
    for (int i = 0; i < 2; i++) {
        sort(tab[i], tab[i] + 18);
    }
    
    int s1 = 0, s2 = 0;
    for (int j = 0; j < 18; j++) s1 += tab[0][j];
    for (int j = 0; j < 18; j++) s2 += tab[1][j];

    if (s1 > s2) {
        cout << "Algosia" << endl;
        return  0;
    }
    else if (s1 < s2) {
        cout << "Bajtek" << endl;
        return 0;
    }
    else {
        for (int i = 17; i >= 0; i--) {
            if (tab[0][i] != tab[1][i]) {
                if (tab[0][i] > tab[1][i]) cout << "Algosia" << endl;
                else cout << "Bajtek" << endl;
                return 0;
            }
        }
    }
    cout << "remis" << endl;

    return 0;
}