Problem p02862 (C++)

Buggy submission (status: Runtime Error):
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/16 20:26:13
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
#define dbg(args...)                                                           \
  do {                                                                         \
    cout << #args << " -> ";                                                   \
    err(args);                                                                 \
  } while (0)
void err() { std::cout << '\n'; }
template <typename T, typename... Args> void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
#else
#define dbg(...)
#endif
void pt() { std::cout << '\n'; }
template <typename T, typename... Args> void pt(T a, Args... args) {
  std::cout << a << ' ';
  pt(args...);
}
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
// head
const int N = 1e6 + 15, MOD = 1e9 + 7;

int fac[N];

ll qpow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = ans * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ans;
}

int C(int n, int m) {
  return 1ll * fac[n] * qpow(fac[n - m], MOD - 2) % MOD *
         qpow(fac[m], MOD - 2) % MOD;
}

void run() {
  fac[0] = 1;
  for (int i = 1; i < N; i++)
    fac[i] = 1ll * fac[i - 1] * i % MOD;
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0;
    return;
  }
  int t = (x + y) / 3;
  if (y - t <= t) {
    cout << C(t, y - t);
  } else
    cout << 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}

Fixed submission:
/*
 * Author:  heyuhhh
 * Created Time:  2019/11/16 20:26:13
 */
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
#define dbg(args...)                                                           \
  do {                                                                         \
    cout << #args << " -> ";                                                   \
    err(args);                                                                 \
  } while (0)
void err() { std::cout << '\n'; }
template <typename T, typename... Args> void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
#else
#define dbg(...)
#endif
void pt() { std::cout << '\n'; }
template <typename T, typename... Args> void pt(T a, Args... args) {
  std::cout << a << ' ';
  pt(args...);
}
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
// head
const int N = 1e6 + 15, MOD = 1e9 + 7;

int fac[N];

ll qpow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = ans * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ans;
}

int C(int n, int m) {
  return 1ll * fac[n] * qpow(fac[n - m], MOD - 2) % MOD *
         qpow(fac[m], MOD - 2) % MOD;
}

void run() {
  fac[0] = 1;
  for (int i = 1; i < N; i++)
    fac[i] = 1ll * fac[i - 1] * i % MOD;
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0;
    return;
  }
  int t = (x + y) / 3;
  if (y - t >= 0 && y - t <= t) {
    cout << C(t, y - t);
  } else
    cout << 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}