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
59
60
61
62
#include <iostream>
#include <vector>

using namespace std;

#define CONTESTANTS 2
#define PROBLEMS 18
#define MAX_POINTS 10

void solve() {
    vector<vector<int>> points(CONTESTANTS, vector<int>(PROBLEMS, 0));
    for(int i = 0; i < CONTESTANTS; i++) {
        for(int j = 0; j < PROBLEMS; j++) {
            cin >> points[i][j];
        }
    }

    vector<int> sums(CONTESTANTS, 0);

    for(int i = 0; i < CONTESTANTS; i++) {
        for(int j = 0; j < PROBLEMS; j++) {
            sums[i] += points[i][j];
        }
    }

    if(sums[0] > sums[1]) {
        cout << "Algosia\n";
        return;
    } else if(sums[1] > sums[0]) {
        cout << "Bajtek\n";
        return;
    }

    vector<vector<int>> points_count(MAX_POINTS + 1, vector<int>(CONTESTANTS, 0));

    for(int i = 0; i < CONTESTANTS; i++) {
        for(int j = 0; j < PROBLEMS; j++) {
            points_count[points[i][j]][i]++;
        }
    }
    
    for(int i = MAX_POINTS; i > 0; i--) {
        if(points_count[i][0] > points_count[i][1]) {
            cout << "Algosia\n";
            return;
        } else if(points_count[i][1] > points_count[i][0]) {
            cout << "Bajtek\n";
            return;
        }
    }
    
    cout << "remis\n";
}

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

    solve();

    return 0;
}