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
#include <stdio.h>

#include <algorithm>
#include <numeric>
#include <vector>

constexpr auto NAME1 = "Algosia";
constexpr auto NAME2 = "Bajtek";
constexpr auto DRAW = "remis";

void solve(std::vector<int>& v1, std::vector<int>& v2) {
  std::sort(v1.rbegin(), v1.rend());
  std::sort(v2.rbegin(), v2.rend());
  const int s1 = std::accumulate(v1.begin(), v1.end(), 0);
  const int s2 = std::accumulate(v2.begin(), v2.end(), 0);

  if (s1 != s2) {
    if (s1 < s2) {
      printf("%s\n", NAME2);
    } else {
      printf("%s\n", NAME1);
    }
  } else {
    for (int i = 0; i < 18; i++) {
      if (v1[i] != v2[i]) {
        if (v1[i] < v2[i]) {
          printf("%s\n", NAME2);
        } else {
          printf("%s\n", NAME1);
        }
        return;
      }
    }
    printf("%s\n", DRAW);
  }
}

int main() {
  std::vector<int> v1, v2;
  int value;
  for (int i = 0; i < 18; ++i) {
    scanf("%d", &value);
    v1.push_back(value);
  }
  for (int i = 0; i < 18; ++i) {
    scanf("%d", &value);
    v2.push_back(value);
  }
  solve(v1, v2);
  return 0;
}