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

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 2137
#endif

const int N = 18, A = 10;

void answer(const string& s) {
  cout << s << '\n';
  exit(0);
}

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

	vector<int> cnt_a(A+1), cnt_b(A+1);
	int sum_a = 0, sum_b = 0;

	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		sum_a += a;
		cnt_a[a]++;
	}
	for (int i = 0; i < N; i++) {
		int b; cin >> b;
		sum_b += b;
		cnt_b[b]++;
	}

  if (sum_a == sum_b) {
    for (int s = A; s >= 0; s--) {
      if (cnt_a[s] != cnt_b[s]) {
        answer(cnt_a[s] > cnt_b[s] ? "Algosia" : "Bajtek");
      }
    }
    answer("remis");
  }
  answer(sum_a > sum_b ? "Algosia" : "Bajtek");
}