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

const int MAX = 20;
int A[MAX], B[MAX];
int cntA[MAX], cntB[MAX];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n = 18, sa = 0, sb = 0;
    for (int i = 0; i < n; i++){
        cin >> A[i];
        sa += A[i];
        cntA[A[i]]++;
    }
    for (int i = 0; i < n; i++){
        cin >> B[i];
        sb += B[i];
        cntB[B[i]]++;
    }
    if (sa == sb){
        int i = 10;
        while (i >= 0 && cntA[i] == cntB[i]){
            i--;
        } 
        if (i < 0 || cntA[i] == cntB[i]){
            cout << "remis\n";
        } else {
            cout << (cntA[i] > cntB[i] ? "Algosia\n" : "Bajtek\n");
        }
    } else {
        cout << (sa > sb ? "Algosia\n" : "Bajtek\n");
    }
}