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
/*
 * Author: Kajetan Ramsza
 * Time: 2024-03-11 12:01:09
**/
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename F, typename S> ostream& operator<<(ostream& os, const pair<F, S> &p) { return os<<"("<<p.first<<", "<<p.second<<")"; }
template<typename T> ostream &operator<<(ostream & os, const vector<T> &v) { os << "{"; typename vector<T> :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; }

void dbg_out() { cerr<<'\n'; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr<<' '<<H; dbg_out(T...); }

#ifdef DEBUG
#define dbg(...) cerr<<"(" << #__VA_ARGS__ <<"):", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 
#endif

const int n = 18;
const int d = 10;

inline void winner(int a, int b) {
	dbg(a, b);
	if(a > b) {
		cout<<"Algosia\n";
		exit(0);
	} else if(a < b) {
		cout<<"Bajtek\n";
		exit(0);	
	} 
}

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

    vi a(d+1,0), b(d+1,0);
    int sum_a = 0, sum_b = 0;
    rep(i,0,n) {
    	int x;
    	cin>>x;
    	a[x]++;
    	sum_a += x;
    }
    rep(i,0,n) {
    	int x;
    	cin>>x;
    	b[x]++;
    	sum_b += x;
    }
    dbg(sum_a, sum_b);
    dbg(a, b);
    winner(sum_a, sum_b);
    for(int i=d;i>=0;i--) {
    	winner(a[i], b[i]);
    }
    cout<<"remis\n";
}