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
#include <iostream>
#include <string>

using namespace std;

int convertLineToArrayAndReturnSum(string &str, int (&arr)[18]) {
    string delimiter = " ";
    int sumOfPoints = 0;

    size_t pos = 0;
    int i = 0;
    string token;
    int intToken;
    while ((pos = str.find(delimiter)) != string::npos) {
        token = str.substr(0, pos);
        intToken = stoi(token);
        arr[i] = intToken;
        sumOfPoints += intToken;
        str.erase(0, pos + delimiter.length());
        i++;
    }

    intToken = stoi(str);
    arr[i] = intToken;
    sumOfPoints += intToken;

    return sumOfPoints;
}

int countOccurrences(int (&arr)[18], int numb) {
    int count = 0;
    for(int i = 0; i < 18; i++) {

        if(arr[i] == numb) {

            count += 1;
        }
    }



    return count;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string algosia, bajtek;
    getline (cin, algosia);
    getline (cin, bajtek);

    int first[18];
    int second[18];

    int firstSum = convertLineToArrayAndReturnSum(algosia, first);
    int secondSum = convertLineToArrayAndReturnSum(bajtek, second);

    //printArr(first);

    // checking if it isnt draw and we can get already a winner
    if(firstSum > secondSum) {
        cout << "Algosia\n";
        return 0;
    } else if(firstSum < secondSum) {
        cout << "Bajtek\n";
        return 0;
    }



    // counting 10's and so on
    int firstOccurrences, secondOccurrences;
    for(int i = 10; i > 0; i--) {
        firstOccurrences = countOccurrences(first, i);
        secondOccurrences = countOccurrences(second, i);

        if(firstOccurrences > secondOccurrences) {
            cout << "Algosia\n";
            return 0;
        } else if(firstOccurrences < secondOccurrences) {
            cout << "Bajtek\n";
            return 0;
        }
    }

    cout << "remis\n";
    return 0;
}