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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#include <iostream>
#include <map>

/* 10 10 7 10 10 10 10 10 10 10 10 10 0 10 4 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 4 3 4 10 10 10*/

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    map<int, int> Algosia;
    map<int, int> Bajtek;
    int cnt = 0;
    int tmp;
    int sumAlgosia = 0;
    int sumBajtek = 0;
    bool bA = false;
    bool bB = false;
    int nWinner = -1;

    for (int i = 0; i < 18; i++)
    {
        cin >> tmp;
        Algosia[tmp]++;
    }

    for (int i = 0; i < 18; i++)
    {
        cin >> tmp;
        Bajtek[tmp]++;
    }

    for (auto i : Algosia)
    {
        // cout << i.first << ":\t" << i.second << endl;
        sumAlgosia += i.first * i.second;
    }

    for (auto i : Bajtek)
    {
        // cout << i.first << ":\t" << i.second << endl;
        sumBajtek += i.first * i.second;
    }
    // cout << "Algosia: " << sumAlgosia << endl;
    // cout << "Bajtek: " << sumBajtek << endl;

    if (sumAlgosia > sumBajtek)
        cout << "Algosia\n";
    if (sumAlgosia < sumBajtek)
        cout << "Bajtek\n";
    if (sumAlgosia == sumBajtek)
    {
        for (int i = 10; i >= 0; i--)
        {
            bA = false;
            bB = false;

            if (Algosia.find(i) != Algosia.end())
            {
                bA = true;
            }

            if (Bajtek.find(i) != Bajtek.end())
            {
                
                bB = true;
            }
            
            if(bA && bB)
            {
                if(Algosia[i]>Bajtek[i])
                {
                    nWinner=0;
                    break;
                }
                else if( Algosia[i]<Bajtek[i])
                {
                    nWinner=1;
                    break;
                }
            }
            if(bA && !bB)
            {
                nWinner = 0;
                break;
            }
            if (!bA && bB)
            {
                nWinner = 1;
                break;
            }
        }
        if(nWinner == 0) cout << "Algosia\n";
        else if(nWinner == 1) cout << "Bajtek\n";
        else if(nWinner == -1 ) cout << "remis\n";
    }

    return 0;
}