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
63
64
65
66
67
68
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    vector<int> a, b;
    int x;
    int s1 = 0, s2 = 0;
    for(int i = 0; i < 18; i++){
        cin >> x;
        s1 += x;
        a.push_back(x);
    }
    
    for(int i = 0; i < 18; i++){
        cin >> x;
        s2 += x;
        b.push_back(x);
    }
    
    if(s1 > s2){
        cout << "Algosia\n";
        return 0;
    }
    
    if(s2 > s1){
        cout << "Bajtek\n";
        return 0;
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    int akt = 10;
    while(a.size() && b.size()){
        int cnt1 = 0, cnt2 = 0;
        if(a.back() < akt && b.back() < akt){
            akt--;
            continue;
        }
        
        while(a.size() && a.back() == akt){
            a.pop_back();
            cnt1++;
        }
        
        while(b.size() && b.back() == akt){
            b.pop_back();
            cnt2++;
        }
        
        akt--;
        if(cnt1 > cnt2){
            cout << "Algosia\n";
            return 0;
        }else if(cnt2 > cnt1){
            cout << "Bajtek\n";
            return 0;
        }
    }
    
    cout << "remis\n";
    return 0;
}