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
#include<stdio.h>
inline char nc()
{
	static char buf[99999],*l,*r;
	return l==r&&(r=(l=buf)+fread(buf,1,99999,stdin),l==r)?EOF:*l++;
}
inline void read(int&x)
{
	char c=nc();for(;c<'0'||'9'<c;c=nc());
	for(x=0;'0'<=c&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=nc());
}
int a[11],b[11],sa,sb;
main()
{
	for(int i=18,x;i--;read(x),++a[x],sa+=x);
	for(int i=18,x;i--;read(x),++b[x],sb+=x);
	if(sa>sb){printf("Algosia");return 0;}
	if(sa<sb){printf("Bajtek");return 0;}
	for(int i=10;i;--i)
	{
		if(a[i]>b[i]){printf("Algosia");return 0;}
		if(a[i]<b[i]){printf("Bajtek");return 0;}
	}
	printf("remis");
}