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

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    int sum_a = 0, sum_b = 0;
    vector<int> a(18, 0); for(auto &k: a){cin>>k; sum_a += k;}
    vector<int> b(18, 0); for(auto &k: b){cin>>k; sum_b += k;}

    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());

    if(sum_a != sum_b){
        if(sum_a > sum_b) cout<<"Algosia"; else cout<<"Bajtek";
    } else{
        int res = 0;
        for(int i=0; i<18; i++){
            if(res != 0) continue;
            if(a[i] > b[i]) res = 1;
            else if(a[i] < b[i]) res = 2;
            else res = 0;
        }
        
        if(res == 0) cout<<"remis";
        else if(res == 1) cout<<"Algosia";
        else cout<<"Bajtek";
    }
}