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
#if defined(EMBE_DEBUG) && !defined(NDEBUG)
#include "embe-debug.hpp"
#else
#define LOG_INDENT(...) do {} while (false)
#define LOG(...) do {} while (false)
#define DUMP(...) do {} while (false)
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <compare>
#include <cstddef>
#include <functional>
#include <iostream>
using namespace std;

namespace {

constexpr size_t n = 18;

class Scores {
  array<int, n> scores = {};
  int total = 0;

  friend istream& operator>>(istream& is, Scores& res)
  {
    res.total = 0;
    for (auto& x: res.scores) {
      is >> x;
      res.total += x;
    }
    ranges::sort(res.scores, greater());
    return is;
  }

  friend weak_ordering operator<=>(Scores const& lhs, Scores const& rhs)
  {
    if (auto res = lhs.total <=> rhs.total; res != 0) return res;
    return lhs.scores <=> rhs.scores;
  }
};

}

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

  Scores a, b;
  cin >> a;
  cin >> b;

  auto res = a <=> b;
  if (res == weak_ordering::greater) {
    cout << "Algosia\n";
  } else if (res == weak_ordering::less) {
    cout << "Bajtek\n";
  } else {
    assert(res == weak_ordering::equivalent);
    cout << "remis\n";
  }

  return 0;
}