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
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define all(x) begin(x),end(x)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve()
{
    vi a(18),b(18);
    int s1=0,s2=0;
    vi c1(11,0),c2(11,0);
    for(auto& x:a)
    {
        cin>>x;
        s1+=x;
        ++c1[x];
    }
    for(auto& x:b)
    {   
        cin>>x;
        s2+=x;
        ++c2[x];
    }
    if(s1>s2)
    {
        cout<<"Algosia"<<endl;
        return;
    }
    if(s2<s1)
    {
        cout<<"Bajtek"<<endl;
        return;
    }
    int i=10;
    while(i>=0&&c1[i]==c2[i])
        --i;
    if(i<0)
    {
        cout<<"remis"<<endl;
        return;
    }
    if(c1[i]>c2[i])
        cout<<"Algosia"<<endl;
    else
        cout<<"Bajtek"<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int z=1;
    //cin>>z;
    while(z--)
        solve();
    return 0;
}