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

#define vec vector
#define all(m) (m).begin(), (m).end()

int main() {
	int sa = 0, sb = 0;
	vec <int> ca(11), cb(11);
	for (int i = 0; i < 18; ++i){
		int x; cin >> x;
		++ca[x];
		sa += x;
	}
	for (int i = 0; i < 18; ++i){
		int x; cin >> x;
		++cb[x];
		sb += x;
	}
	ca.push_back(sa);
	cb.push_back(sb);
	reverse(all(ca));
	reverse(all(cb));
	cout << (ca < cb ? "Bajtek" : ca == cb ? "remis" : "Algosia");
	return 0;
}