Problem p03742 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int(i) = 0; (i) < (N); ++(i))
#define READALL(c)                                                             \
  for (auto &e : c) {                                                          \
    cin >> e;                                                                  \
  }
#define PRINTALL(c)                                                            \
  for (const auto &e : c) {                                                    \
    cout << e << "\t";                                                         \
  }                                                                            \
  cout << "\n";

template <typename T> using V = vector<T>;

typedef long double ld;

V<V<int>> DP(1000, V<int>(1000, -1));

int f(int x, int y) {
  if (x < 2 && y < 2)
    return 0;
  if (DP[x][y] != -1)
    return DP[x][y];
  for (int i = 1; 2 * i <= x; ++i) {
    if (!f(x - 2 * i, y + i))
      return DP[x][y] = 1;
  }
  for (int i = 1; 2 * i <= y; ++i) {
    if (!f(x + i, y - 2 * i))
      return DP[x][y] = 1;
  }

  return DP[x][y] = 0;
}

int f2(int64_t x, int64_t y) {
  if (x < 2 && y < 2)
    return 0;

  if (y >= x - 1 && y <= x + 1) {
    return 0;
  } else {
    return 1;
  }
}

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

  int64_t X, Y;
  cin >> X >> Y;

  cout << (f(X, Y) ? "Alice" : "Brown") << endl;

  // for (int x = 0; x < 100; ++x) {
  // 	for (int y = 0; y < 100; ++y) {
  // 		cout << x << " " << y << ": " << f(x, y) << endl;
  // 		assert(f(x,y) == f2(x, y));
  // 	}
  // }
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int(i) = 0; (i) < (N); ++(i))
#define READALL(c)                                                             \
  for (auto &e : c) {                                                          \
    cin >> e;                                                                  \
  }
#define PRINTALL(c)                                                            \
  for (const auto &e : c) {                                                    \
    cout << e << "\t";                                                         \
  }                                                                            \
  cout << "\n";

template <typename T> using V = vector<T>;

typedef long double ld;

V<V<int>> DP(1000, V<int>(1000, -1));

int f(int x, int y) {
  if (x < 2 && y < 2)
    return 0;
  if (DP[x][y] != -1)
    return DP[x][y];
  for (int i = 1; 2 * i <= x; ++i) {
    if (!f(x - 2 * i, y + i))
      return DP[x][y] = 1;
  }
  for (int i = 1; 2 * i <= y; ++i) {
    if (!f(x + i, y - 2 * i))
      return DP[x][y] = 1;
  }

  return DP[x][y] = 0;
}

int f2(int64_t x, int64_t y) {
  if (x < 2 && y < 2)
    return 0;

  if (y >= x - 1 && y <= x + 1) {
    return 0;
  } else {
    return 1;
  }
}

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

  int64_t X, Y;
  cin >> X >> Y;

  cout << (f2(X, Y) ? "Alice" : "Brown") << endl;

  // for (int x = 0; x < 100; ++x) {
  // 	for (int y = 0; y < 100; ++y) {
  // 		cout << x << " " << y << ": " << f(x, y) << endl;
  // 		assert(f(x,y) == f2(x, y));
  // 	}
  // }
}