alexjercan/bugnet huggingface dataset:
Problem p02878 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
using std::min;
#define mod 998244353
#define int long long
int fac[20001000], inv[20001000], n, a, b, ans;
int quickpow(int x, int y) {
  if (y == 0)
    return 1;
  if (y % 2 == 0)
    return quickpow(x * x % mod, y / 2);
  if (y % 2 == 1)
    return quickpow(x * x % mod, y / 2) * x % mod;
}
int C(int x, int y) {
  if (y < 0 || x < y)
    return 0;
  if (y == 0 || x == y)
    return 1;
  return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int Catalan(int x, int y) {
  return ((C(x + y, y) - C(x + y, y - 1)) + mod) % mod;
}
signed main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  if (b == 0)
    return puts("1"), 0;
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % mod;
  inv[n] = quickpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % mod;
  for (int i = 0; i <= min(min(a, n - b), b - 1); i++) {
    int tot = Catalan(b - 1, i);
    if (i == n - b) {
      if (a == i)
        (ans += tot) %= mod;
    } else {
      int x = n - b - i - 1;
      int y = a - i + 1;
      (ans += tot * C(x + y - 1, x) % mod) %= mod;
    }
  }
  printf("%lld\\n", ans);
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
using std::min;
#define mod 998244353
#define int long long
int fac[20001000], inv[20001000], n, a, b, ans;
int quickpow(int x, int y) {
  if (y == 0)
    return 1;
  if (y % 2 == 0)
    return quickpow(x * x % mod, y / 2);
  if (y % 2 == 1)
    return quickpow(x * x % mod, y / 2) * x % mod;
}
int C(int x, int y) {
  if (y < 0 || x < y)
    return 0;
  if (y == 0 || x == y)
    return 1;
  return fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int Catalan(int x, int y) {
  return ((C(x + y, y) - C(x + y, y - 1)) + mod) % mod;
}
signed main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  if (b == 0)
    return puts("1");
  fac[0] = 1;
  for (int i = 1; i <= 2 * n; i++)
    fac[i] = fac[i - 1] * i % mod;
  inv[2 * n] = quickpow(fac[2 * n], mod - 2);
  for (int i = 2 * n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % mod;
  for (int i = 0; i <= min(min(a, n - b), b - 1); i++) {
    int tot = Catalan(b - 1, i);
    if (i == n - b) {
      if (a == i)
        (ans += tot) %= mod;
    } else {
      int x = n - b - i - 1;
      int y = a - i + 1;
      (ans += tot * C(x + y - 1, x) % mod) %= mod;
    }
  }
  printf("%lld\\n", ans);
}
Problem p02878 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
#define fr(i, a, b) for (int i(a), end##i(b); i <= end##i; i++)
#define fd(i, a, b) for (int i(a), end##i(b); i >= end##i; i--)
using namespace std;
const int mod = 998244353;
const int maxn = 4e7 + 5;
int ksm(int x, int k) {
  int ans = 1;
  while (k) {
    if (k & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return ans;
}
int jc[maxn], inv[maxn];
void init(int n) {
  jc[0] = 1;
  fr(i, 1, n) jc[i] = jc[i - 1] * i % mod;
  inv[n] = ksm(jc[n], mod - 2);
  fd(i, n - 1, 0) inv[i] = inv[i + 1] * (i + 1) % mod;
}
int C(int n, int m) {
  if (n < 0 || m < 0 || n < m)
    return 0;
  return jc[n] * inv[m] % mod * inv[n - m] % mod;
}
int D(int n, int m) {
  if (n < 0 || n + m < 0 || ((n + m) & 1))
    return 0;
  return C(n, n + m >> 1);
}
int x, y, t, ans;
signed main() {
#ifdef pig
  freopen("f.in", "r", stdin);
  freopen("f.out", "w", stdout);
#endif
  cin >> t >> y >> x;
  if (!x && !y && t) {
    cout << 1;
    return 0;
  }
  init(3e7);
  y = x - y;
  if (2 * x - t - y == 0)
    ans = D(t - 1, 2 * x - t - 1) - D(t - 1, 2 * x - t + 1);
  fr(k, 1, 2 * x - y) {
    int h = 2 * x - k - y;
    (ans += C(h + t - k - 1, h) *
            (D(k - 1, 2 * x - k - 1) - D(k - 1, 2 * x - k + 1))) %= mod;
  }
  cout << (ans + mod) % mod;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define fr(i, a, b) for (int i(a), end##i(b); i <= end##i; i++)
#define fd(i, a, b) for (int i(a), end##i(b); i >= end##i; i--)
using namespace std;
const int mod = 998244353;
const int maxn = 1e7 + 5;
int ksm(int x, int k) {
  int ans = 1;
  while (k) {
    if (k & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return ans;
}
int jc[maxn], inv[maxn];
void init(int n) {
  jc[0] = 1;
  fr(i, 1, n) jc[i] = jc[i - 1] * i % mod;
  inv[n] = ksm(jc[n], mod - 2);
  fd(i, n - 1, 0) inv[i] = inv[i + 1] * (i + 1) % mod;
}
int C(int n, int m) {
  if (n < 0 || m < 0 || n < m)
    return 0;
  return jc[n] * inv[m] % mod * inv[n - m] % mod;
}
int D(int n, int m) {
  if (n < 0 || n + m < 0 || ((n + m) & 1))
    return 0;
  return C(n, n + m >> 1);
}
int x, y, t, ans;
signed main() {
#ifdef pig
  freopen("f.in", "r", stdin);
  freopen("f.out", "w", stdout);
#endif
  cin >> t >> y >> x;
  if (!x && !y && t) {
    cout << 1;
    return 0;
  }
  init(1e6);
  y = x - y;
  if (2 * x - t - y == 0)
    ans = D(t - 1, 2 * x - t - 1) - D(t - 1, 2 * x - t + 1);
  fr(k, 1, 2 * x - y) {
    int h = 2 * x - k - y;
    (ans += C(h + t - k - 1, h) *
            (D(k - 1, 2 * x - k - 1) - D(k - 1, 2 * x - k + 1))) %= mod;
  }
  cout << (ans + mod) % mod;
  return 0;
}