prithivMLmods/Coder-Stat huggingface dataset:
Problem p02769 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
const int MAX = 200001;
const int MOD = 1000000007;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  ll n, k, ans = 0;
  cin >> n >> k;
  COMinit();
  rep(i, k + 1) ans = (ans + COM(n, i) * COM(n - 1, n - 1 - i) % MOD) % MOD;
  print(ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
const int MAX = 200001;
const int MOD = 1000000007;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  ll n, k, ans = 0;
  cin >> n >> k;
  COMinit();
  rep(i, min(n - 1, k) + 1) ans =
      (ans + COM(n, i) * COM(n - 1, n - 1 - i) % MOD) % MOD;
  print(ans);
  return 0;
}
Problem p02769 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll modulo = 1000000007ll;

ll binpow(ll a, ll b) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    return (binpow(a, b / 2) * binpow(a, b / 2)) % modulo;
  } else {
    return (((binpow(a, b / 2) * binpow(a, b / 2)) % modulo) * a) % modulo;
  }
}

ll factorial(ll n) {
  ll temp = 1;
  for (ll i = n; i >= 1; --i) {
    temp = (temp * i) % modulo;
  }
  return temp;
}

ll factorial1(ll n, ll p) {
  ll temp = 1;
  for (ll i = n; i >= (p + 1); --i) {
    temp = (temp * i) % modulo;
  }
  return temp;
}

ll moduloinverse(ll n) {
  /// cout<<"dvsd"<<endl;
  ll p = modulo - 2;
  return binpow(n, p) % modulo;
}
ll com(ll n, ll r) {
  if (r == 0)
    return 1;
  ll temp1 = std::max(r, n - r);
  ll temp2 = std::min(r, n - r);
  ll a = factorial1(n, temp1);
  ll b = factorial(temp2);
  // cout<<a<<" "<<b<<endl;
  return (a * moduloinverse(b)) % modulo;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  ll temp = std::min(k, n - 1);
  for (ll i = 0; i <= temp; ++i) {

    ans = (ans + (com(n, i) * com(n - 1, i)) % modulo) % modulo;
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll modulo = 1000000007ll;

ll binpow(ll a, ll b) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    return (binpow(a, b / 2) * binpow(a, b / 2)) % modulo;
  } else {
    return (((binpow(a, b / 2) * binpow(a, b / 2)) % modulo) * a) % modulo;
  }
}

ll factorial(ll n) {
  ll temp = 1;
  for (ll i = n; i >= 1; --i) {
    temp = (temp * i) % modulo;
  }
  return temp;
}

ll factorial1(ll n, ll p) {
  ll temp = 1;
  for (ll i = n; i >= (p + 1); --i) {
    temp = (temp * i) % modulo;
  }
  return temp;
}

ll moduloinverse(ll n) {
  /// cout<<"dvsd"<<endl;
  ll p = modulo - 2;
  return binpow(n, p) % modulo;
}
ll com(ll n, ll r) {
  if (r == 0)
    return 1;
  ll temp1 = std::max(r, n - r);
  ll temp2 = std::min(r, n - r);
  ll a = factorial1(n, temp1);
  ll b = factorial(temp2);
  // cout<<a<<" "<<b<<endl;
  return (a * moduloinverse(b)) % modulo;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  ll temp = std::min(k, n - 1);
  ll first = (com(n, 0) * com(n - 1, 0)) % modulo;
  ans = first;
  for (ll i = 0; i <= temp - 1; ++i) {
    ll v = ((n - i) * (n - i - 1)) % modulo;
    v = (v * first) % modulo;
    ll u = ((i + 1) * (i + 1)) % modulo;
    v = (v * moduloinverse(u)) % modulo;
    ans = (ans + v) % modulo;
    first = v;
    // cout<<first<<" ";
  }

  cout << ans << endl;
}
Problem p02769 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long mod = 1e9 + 7;
struct all {
  vector<long long> kai, gya, nck;
  all(long long n) {
    kai.resize(n);
    gya.resize(n);
    nck.resize(n);
  }
  long long pow(long long x, long long n) {
    long long ret = 1;
    if (n > 0) {
      ret = pow(x, n / 2);
      if (n % 2 == 0) {
        (ret = (ret * ret)) %= mod;
      } else {
        (ret = ((ret * ret) % mod) * x) %= mod;
      }
    }
    return ret;
  }
  long long inv(long long n) { return pow(n, mod - 2); }
  vector<long long> cul(long long n) {
    kai[n] = n;
    for (int i = n - 1; i > 0; i--) {
      (kai[i] = kai[i + 1] * i) %= mod;
    }
    gya[1] = inv(1);
    for (int i = 2; i <= n; i++) {
      (gya[i] = gya[i - 1] * inv(i)) %= mod;
    }
    for (int i = 1; i <= n; i++) {
      (nck[i] = kai[n + 1 - i] * gya[i]) %= mod;
    }
    nck[0] = 1;
    nck[n] = 1;
    return nck;
  }
};
int main() {
  long long n, k;
  cin >> n >> k;
  if (k >= n - 1) {
    all nii(2 * n - 1);
    vector<long long> hoge = nii.cul(2 * n - 1);
    cout << hoge[n] << endl;
  } else {
    long long ans = 0;
    all nii(n);
    all mii(n - 1);
    vector<long long> hogen = nii.cul(n);
    vector<long long> hogenn = mii.cul(n - 1);
    for (int i = 0; i <= k; i++) {
      (ans += (hogen[i] * hogenn[i])) %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long mod = 1e9 + 7;
struct all {
  vector<long long> kai, gya, nck;
  all(long long n) {
    kai.resize(n + 1);
    gya.resize(n + 1);
    nck.resize(n + 1);
  }
  long long pow(long long x, long long n) {
    long long ret = 1;
    if (n > 0) {
      ret = pow(x, n / 2);
      if (n % 2 == 0) {
        (ret = (ret * ret)) %= mod;
      } else {
        (ret = ((ret * ret) % mod) * x) %= mod;
      }
    }
    return ret;
  }
  long long inv(long long n) { return pow(n, mod - 2); }
  vector<long long> cul(long long n) {
    kai[n] = n;
    for (int i = n - 1; i > 0; i--) {
      (kai[i] = kai[i + 1] * i) %= mod;
    }
    gya[1] = inv(1);
    for (int i = 2; i <= n; i++) {
      (gya[i] = gya[i - 1] * inv(i)) %= mod;
    }
    for (int i = 1; i <= n; i++) {
      (nck[i] = kai[n + 1 - i] * gya[i]) %= mod;
    }
    nck[0] = 1;
    nck[n] = 1;
    return nck;
  }
};
int main() {
  long long n, k;
  cin >> n >> k;
  if (k >= n - 1) {
    all nii(2 * n - 1);
    vector<long long> hoge = nii.cul(2 * n - 1);
    cout << hoge[n] << endl;
  } else {
    long long ans = 0;
    all nii(n);
    all mii(n - 1);
    vector<long long> hogen = nii.cul(n);
    vector<long long> hogenn = mii.cul(n - 1);
    for (int i = 0; i <= k; i++) {
      (ans += (hogen[i] * hogenn[i])) %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02769 (C++)

Buggy submission (status: Memory Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)

#define INF 1e9
const ll mod = 1e9 + 7;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll ans = 1;
ll N;
vector<vector<bool>> homon(2 * (int)1e5 + 3, vector<bool>(1e5, false));
void dfs(int n, int lock, int k) {
  if (n <= 0 || k <= 0) {
    return;
  }
  cerr << "n:" << n << " k:" << k << endl;
  if (homon[n][lock])
    return;
  homon[n][lock] = true;
  if (lock != 0) {
    ans += (n * COM(N, lock)) % mod;
    ans %= mod;
    dfs(n - 1, lock, k - 1);
  }
  if (n - 2 >= 0) {
    ans += (n * (n - 1)) % mod;
    ans %= mod;
    dfs(n - 2, lock + 1, k - 1);
  }
}

int main() {
  COMinit();
  ll n, k;
  cin >> n >> k;
  N = n;
  if (k == 1) {
    cout << n * (n - 1) % mod << endl;
    return 0;
  }
  ans = 1;
  FOR(i, 1, min(N + 1, k + 1)) {
    ans += (COM(N, i) * COM(N - i + i - 1, i)) % mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)

#define INF 1e9
const ll mod = 1e9 + 7;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll ans = 1;
ll N;

int main() {
  COMinit();
  ll n, k;
  cin >> n >> k;
  N = n;
  if (k == 1) {
    cout << n * (n - 1) % mod << endl;
    return 0;
  }
  ans = 1;
  FOR(i, 1, min(N + 1, k + 1)) {
    ans += (COM(N, i) * COM(N - i + i - 1, i)) % mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}
Problem p02769 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)

using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();
  ll n, k;
  cin >> n >> k;
  ll res = 0;
  for (ll i = 0; i <= k; i++) {
    res += COM(n, i) * COM(n - 1, n - i - 1) % mod;
    res %= mod;
  }

  cout << res << endl;
}

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)

using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();
  ll n, k;
  cin >> n >> k;
  ll res = 0;
  for (ll i = 0; i <= min(n, k); i++) {
    res += COM(n, i) * COM(n - 1, n - i - 1) % mod;
    res %= mod;
  }

  cout << res << endl;
}
Problem p02769 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

const int MAX = 400000;     // 欲しい最大数に応じて変動 n*2でOK
const int MOD = 1000000007; // 10^9+7用mod

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long long a, b;
  cin >> a >> b;
  COMinit();

  if (a <= b) {
    long long total;
    total = COM(a * 2 - 1, a - 1);
    cout << total << endl;
  }

  else {
    long long ans = 0;
    for (int i = 0; i <= b; i++) {
      for (int j = 0; j < b - i; j++) {
        ans = (ans + (COM(a, b - i) * COM(a - b + i, b - i - j) % MOD) *
                         COM(b - i - 1, b - i - 1 - j) % MOD) %
              MOD;
      }
    }
    cout << ans + 1 << endl; // 22583772
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

const int MAX = 400000;     // 欲しい最大数に応じて変動 n*2でOK
const int MOD = 1000000007; // 10^9+7用mod

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  long long a, b;
  cin >> a >> b;
  COMinit();

  if (a <= b) {
    long long total;
    total = COM(a * 2 - 1, a - 1);
    cout << total << endl;
  }

  else {
    long long ans = 0;
    for (int i = 0; i < b; i++) {
      ans = (ans + COM(a, b - i) * COM(a - 1, a - 1 - b + i) % MOD) % MOD;
    }
    cout << ans + 1 << endl; // 22583772
  }
}
Problem p02769 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
template <class t> inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c))
    f |= c == '-', c = getchar();
  while (isdigit(c))
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f)
    x = -x;
  return x;
}
template <class t> inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9)
      write(x / 10);
    putchar('0' + x % 10);
  }
}

#define int long long

const int mod = 1e9 + 7, N = 2e5 + 5;
int n, ans, k, fac[N], inv[N];

int fpow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1)
      res = res * x % mod;
  return res;
}

int C(int x, int y) {
  if (x < y || x < 0)
    return 0;
  return fac[x] * inv[y] % mod * inv[x - y] % mod;
}

signed main() {
  read(n);
  read(k);
  fac[0] = 1;
  for (int i = 1; i <= n + n; i++)
    fac[i] = fac[i - 1] * i % mod;
  inv[n + n] = fpow(fac[n + n], mod - 2);
  for (int i = n + n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % mod;
  for (int i = max(1ll, n - k); i <= n; i++)
    ans = (ans + C(n, i) * C(n - 1, i - 1) % mod) % mod;
  write(ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <class t> inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c))
    f |= c == '-', c = getchar();
  while (isdigit(c))
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f)
    x = -x;
  return x;
}
template <class t> inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9)
      write(x / 10);
    putchar('0' + x % 10);
  }
}

#define int long long

const int mod = 1e9 + 7, N = 4e5 + 5;
int n, ans, k, fac[N], inv[N];

int fpow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1)
      res = res * x % mod;
  return res;
}

int C(int x, int y) {
  if (x < y || x < 0)
    return 0;
  return fac[x] * inv[y] % mod * inv[x - y] % mod;
}

signed main() {
  read(n);
  read(k);
  fac[0] = 1;
  for (int i = 1; i <= n + n; i++)
    fac[i] = fac[i - 1] * i % mod;
  inv[n + n] = fpow(fac[n + n], mod - 2);
  for (int i = n + n - 1; i >= 0; i--)
    inv[i] = inv[i + 1] * (i + 1) % mod;
  for (int i = max(1ll, n - k); i <= n; i++)
    ans = (ans + C(n, i) * C(n - 1, i - 1) % mod) % mod;
  write(ans);
}
Problem p02769 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
  using lint = long long int;
  int sz;
  lint mod;
  vector<lint> fac;
  vector<lint> finv;
  combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
    fac.assign(sz + 1, 1);
    finv.assign(sz + 1, 1);
    vector<lint> inv(sz + 1, 1);
    for (int i = 2; i <= sz; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  lint query(int n, int r) {
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
  }
};

lint mod = 1e+9 + 7;
lint n, k;

int main() {
  cin >> n >> k;
  combination_mod comb(2 * n, mod);
  if (k >= n - 1) {
    cout << comb.query(2 * n - 1, n) << endl;
  }
  lint ans = (1 + n * (n - 1)) % mod;
  for (int i = 1; i < k; i++) {
    lint ta = comb.query(n, i + 1);
    ta *= comb.query(n - 1, i + 1);
    ta %= mod;
    ans = (ans + ta) % mod;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
  using lint = long long int;
  int sz;
  lint mod;
  vector<lint> fac;
  vector<lint> finv;
  combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
    fac.assign(sz + 1, 1);
    finv.assign(sz + 1, 1);
    vector<lint> inv(sz + 1, 1);
    for (int i = 2; i <= sz; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  lint query(int n, int r) {
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
  }
};

lint mod = 1e+9 + 7;
lint n, k;

int main() {
  cin >> n >> k;
  combination_mod comb(2 * n, mod);
  if (k >= n - 1) {
    cout << comb.query(2 * n - 1, n) << endl;
    return 0;
  }
  if (k == 1) {
    cout << n * (n - 1) % mod << endl;
    return 0;
  }
  lint ans = (1 + n * (n - 1)) % mod;
  for (int i = 1; i < k; i++) {
    lint ta = comb.query(n, i + 1);
    ta *= comb.query(n - 1, i + 1);
    ta %= mod;
    ans = (ans + ta) % mod;
  }
  cout << ans << endl;
}
Problem p02769 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MODN = 1e9 + 7;
const int MAXN = 1e5 + 10;
int fact[MAXN];
int quick_pow(int a, int b, int modn = MODN) {
  a %= MODN;
  int ret = 1;
  // int cheng=a;
  while (b) {
    if (b & 1)
      ret *= a;
    ret %= MODN;
    a *= a;
    a %= MODN;
    b >>= 1;
  }
  return ret;
}
int C(int n, int r) {
  return fact[n] * (quick_pow((fact[n - r] * fact[r]), MODN - 2)) % MODN;
}

int32_t main() {

  int n, k;
  cin >> n >> k;
  fact[0] = 1;
  for (int i = 1; i < MAXN; i++)
    fact[i] = (fact[i - 1] * i) % MODN;
  int sum = 0;
  for (int i = 0; i <= min(k, n - 1); i++) {
    sum += C(n, i) * C(n - 1, i);
    sum %= MODN;
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MODN = 1e9 + 7;
const int MAXN = 2e5 + 10;
int fact[MAXN];
int quick_pow(int a, int b, int modn = MODN) {
  a %= MODN;
  int ret = 1;
  // int cheng=a;
  while (b) {
    if (b & 1)
      ret *= a;
    ret %= MODN;
    a *= a;
    a %= MODN;
    b >>= 1;
  }
  return ret;
}
int C(int n, int r) {
  return fact[n] * (quick_pow((fact[n - r] * fact[r]), MODN - 2)) % MODN;
}

int32_t main() {

  int n, k;
  cin >> n >> k;
  fact[0] = 1;
  for (int i = 1; i < MAXN; i++)
    fact[i] = (fact[i - 1] * i) % MODN;
  int sum = 0;
  for (int i = 0; i <= min(k, n - 1); i++) {
    sum += C(n, i) * C(n - 1, i);
    sum %= MODN;
  }
  cout << sum << endl;
  return 0;
}
Problem p02769 (Python)

Buggy submission (status: Runtime Error):
from functools import lru_cache


CHECK = False

N, K = list(map(int, input().split()))

MOD = 10**9 + 7


@lru_cache(maxsize=None)
def modInverse(a, p):
    # Fermat's little theorem, a**(p-1) = 1 mod p
    return pow(a, p - 2, p)


if CHECK:
    fact = [1]
    for i in range(1, 2 * N + 1):
        fact.append((fact[-1] * i) % MOD)

    def nCr(n, r, p=MOD):
        # Modulo binomial coefficients
        return (fact[n] * modInverse(fact[r], p) * modInverse(fact[n - r], p)) % p


if N - 1 <= K:
    # Any combo is achievable so this is stars and bars
    # N people into N rooms, which means N - 1 dividers
    stars = N
    bars = N - 1
    print(nCr(stars + bars, bars))
else:
    # Group by number of empty rooms
    # With K moves there can only be at most K empty rooms
    # Max of N - 1 empty rooms in general
    assert K + 1 < N
    tot = 0
    comb1 = 1
    comb2 = 1
    for numEmpty in range(K + 1):
        way3 = comb1 * comb2
        if CHECK:
            numNonEmpty = N - numEmpty
            stars = numEmpty  # Everyone moving into an occupied room
            bars = numNonEmpty - 1  # Number of dividers
            way1 = nCr(stars + bars, bars) * nCr(N, numEmpty)

            way2 = nCr(N, numEmpty) * nCr(N - 1, numEmpty)

            assert way1 % MOD == way2 % MOD == way3 % MOD
        tot += way3

        j = numEmpty + 1
        invJ = modInverse(j, MOD)
        comb1 = (N + 1 - j) * comb1 * invJ % MOD
        comb2 = (N - j) * comb2 * invJ % MOD
    print(tot % MOD)


Fixed submission:
from functools import lru_cache


CHECK = False

N, K = list(map(int, input().split()))

MOD = 10**9 + 7


@lru_cache(maxsize=None)
def modInverse(a, p):
    # Fermat's little theorem, a**(p-1) = 1 mod p
    return pow(a, p - 2, p)


if N - 1 <= K or CHECK:
    fact = [1]
    for i in range(1, 2 * N + 1):
        fact.append((fact[-1] * i) % MOD)

    def nCr(n, r, p=MOD):
        # Modulo binomial coefficients
        return (fact[n] * modInverse(fact[r], p) * modInverse(fact[n - r], p)) % p


if N - 1 <= K:
    # Any combo is achievable so this is stars and bars
    # N people into N rooms, which means N - 1 dividers
    stars = N
    bars = N - 1
    print(nCr(stars + bars, bars))
else:
    # Group by number of empty rooms
    # With K moves there can only be at most K empty rooms
    # Max of N - 1 empty rooms in general
    assert K + 1 < N
    tot = 0
    comb1 = 1
    comb2 = 1
    for numEmpty in range(K + 1):
        way3 = comb1 * comb2
        if CHECK:
            numNonEmpty = N - numEmpty
            stars = numEmpty  # Everyone moving into an occupied room
            bars = numNonEmpty - 1  # Number of dividers
            way1 = nCr(stars + bars, bars) * nCr(N, numEmpty)

            way2 = nCr(N, numEmpty) * nCr(N - 1, numEmpty)

            assert way1 % MOD == way2 % MOD == way3 % MOD
        tot += way3

        j = numEmpty + 1
        invJ = modInverse(j, MOD)
        comb1 = (N + 1 - j) * comb1 * invJ % MOD
        comb2 = (N - j) * comb2 * invJ % MOD
    print(tot % MOD)
Problem p02770 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

const ll inf = 1LL << 60;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
  ll k, q;
  cin >> k >> q;
  vector<ll> d(k);
  REP(i, k) { cin >> d[i]; }

  vector<ll> ans(q);
  REP(i, q) {
    ll n, x, m;
    cin >> n >> x >> m;
    x %= m;
    vector<ll> dmod(k), ruiseki(k + 1, 0), zeros(k, 0);
    // ll ruiseki = 0;
    // ll zeros = 0;
    REP(j, k) {
      dmod[j] = d[j] % m;
      // cout << dmod[j] << " ";
      ruiseki[j + 1] = ruiseki[j] + dmod[j];
      if (ruiseki[j + 1] == ruiseki[j]) {
        zeros[j + 1] = zeros[j] + 1; // a1 = a0 + d0 で、d0 = 0 の場合
      } else
        zeros[j + 1] = zeros[j];
    }
    // cout << endl;
    ll shou = (n - 1) / k;
    ll amari = (n - 1) % k;
    ll sum = 0;
    ll zero = 0;
    sum = x + shou * ruiseki[k] + ruiseki[amari];
    zero = zeros[k] * shou + zeros[amari];
    ans[i] = (n - 1) - sum / m - zero;
  }
  REP(i, q) { cout << ans[i] << endl; }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;

const ll inf = 1LL << 60;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
  ll k, q;
  cin >> k >> q;
  vector<ll> d(k);
  REP(i, k) { cin >> d[i]; }

  vector<ll> ans(q);
  REP(i, q) {
    ll n, x, m;
    cin >> n >> x >> m;
    x %= m;
    vector<ll> dmod(k), ruiseki(k + 1, 0), zeros(k + 1, 0);
    // ll ruiseki = 0;
    // ll zeros = 0;
    REP(j, k) {
      dmod[j] = d[j] % m;
      // cout << dmod[j] << " ";
      ruiseki[j + 1] = ruiseki[j] + dmod[j];
      if (ruiseki[j + 1] == ruiseki[j]) {
        zeros[j + 1] = zeros[j] + 1; // a1 = a0 + d0 で、d0 = 0 の場合
      } else
        zeros[j + 1] = zeros[j];
    }
    // cout << endl;
    ll shou = (n - 1) / k;
    ll amari = (n - 1) % k;
    ll sum = 0;
    ll zero = 0;
    sum = x + shou * ruiseki[k] + ruiseki[amari];
    zero = zeros[k] * shou + zeros[amari];
    ans[i] = (n - 1) - sum / m - zero;
  }
  REP(i, q) { cout << ans[i] << endl; }
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d %d %d", a, b, c);
  if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
    printf("Yes");
  else
    printf("No");
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
    printf("Yes");
  else
    printf("No");
  return 0;
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}

int main() {
  mahakal();
  fast;

  ll arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr, arr + 3);
  if ((arr[0] == arr[1] && arr[1] != arr[2]) ||
      (arr[1] == arr[2] && arr[1] != arr[0])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}

int main() {
  //	mahakal();
  fast;

  ll arr[3];
  cin >> arr[0] >> arr[1] >> arr[2];
  sort(arr, arr + 3);
  if ((arr[0] == arr[1] && arr[1] != arr[2]) ||
      (arr[1] == arr[2] && arr[1] != arr[0])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define int long long
const int N = 2e3 + 5;
vector<int> v(3);
int32_t main() {
  IOS;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  // code
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if ((v[0] == v[1] && v[1] != v[2]) || (v[0] != v[1] && v[1] == v[2]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  // code
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define endl "\n"
#define int long long
const int N = 2e3 + 5;
vector<int> v(3);
int32_t main() {
  IOS;

  // code
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if ((v[0] == v[1] && v[1] != v[2]) || (v[0] != v[1] && v[1] == v[2]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  // code
  return 0;
}
Problem p02771 (Python)

Buggy submission (status: Runtime Error):
a, b, c = list(map(int, input().split()))
if len(set(a, b, c)) == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
a = list(map(int, input().split()))
if len(set(a)) == 2:
    print("Yes")
else:
    print("No")
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int d[10];
  for (int i = 0; i < 3; i++)
    scanf("%d", d[i]);
  bool chk = true;
  int v = d[0];
  if (v != d[1]) {
    if (v != d[2]) {
      if (d[1] == d[2])
        chk = true;
      else
        chk = false;
    } else {
      chk = true;
    }
  } else {
    if (d[1] == d[2])
      chk = false;
    else
      chk = true;
  }

  if (chk) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int d[10];
  for (int i = 0; i < 3; i++)
    scanf("%d", &d[i]);
  bool chk = true;
  int v = d[0];
  if (v != d[1]) {
    if (v != d[2]) {
      if (d[1] == d[2])
        chk = true;
      else
        chk = false;
    } else {
      chk = true;
    }
  } else {
    if (d[1] == d[2])
      chk = false;
    else
      chk = true;
  }

  if (chk) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define umax(x, y) x = max(x, (y))
#define umin(x, y) x = min(x, (y))
#define set multiset
#define null NULL
#define ort (b + s) / 2

using namespace std;

typedef long long Lint;
typedef long double db;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<db, db> dd;
typedef pair<int, string> is;

const int maxn = 600020;
const int K = 320;
const int MOd = 1e9 + 7;

int ar[maxn];

void solve() {
  scanf("%d %d %d", ar[1], ar[2], ar[3]);
  sort(ar + 1, ar + 1 + 3);
  if (ar[1] == ar[2] && ar[2] != ar[3]) {
    printf("Yes\n");
    return;
  }
  if (ar[1] != ar[2] && ar[2] == ar[3]) {
    printf("Yes\n");
    return;
  }
  printf("No\n");
}

int main() {

  int n = 1;
  // scanf("%d",&n);
  while (n--)
    solve();

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define umax(x, y) x = max(x, (y))
#define umin(x, y) x = min(x, (y))
#define set multiset
#define null NULL
#define ort (b + s) / 2

using namespace std;

typedef long long Lint;
typedef long double db;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<db, db> dd;
typedef pair<int, string> is;

const int maxn = 600020;
const int K = 320;
const int MOd = 1e9 + 7;

int ar[maxn];

void solve() {
  scanf("%d %d %d", &ar[1], &ar[2], &ar[3]);
  sort(ar + 1, ar + 1 + 3);
  if (ar[1] == ar[2] && ar[2] != ar[3]) {
    printf("Yes\n");
    return;
  }
  if (ar[1] != ar[2] && ar[2] == ar[3]) {
    printf("Yes\n");
    return;
  }
  printf("No\n");
}

int main() {

  int n = 1;
  // scanf("%d",&n);
  while (n--)
    solve();

  return 0;
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a, b) memset(a, b, sizeof(a))
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxm = 1e3 + 10;
using namespace std;
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  srand((unsigned int)time(NULL));
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[4];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if ((a[0] != a[1] && a[0] != a[2] && a[1] != a[2]) ||
      (a[0] == a[1] && a[0] == a[2]))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
#ifndef ONLINE_JUDGE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a, b) memset(a, b, sizeof(a))
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxm = 1e3 + 10;
using namespace std;
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  srand((unsigned int)time(NULL));
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[4];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if ((a[0] != a[1] && a[0] != a[2] && a[1] != a[2]) ||
      (a[0] == a[1] && a[0] == a[2]))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
#ifndef ONLINE_JUDGE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d%d%d", a, b, c);
  if ((a != b && b != c && c != a) || (a == b && a == c)) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
}

Fixed submission:
#include <iostream>
#include <stdio.h>
int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if ((a != b && b != c && c != a) || (a == b && a == c)) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
}
Problem p02771 (Python)

Buggy submission (status: Runtime Error):
A, B, C = map(int, input().split())
list = [A, B, C]
ans = list(set(list))
if len(ans) == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
A, B, C = map(int, input().split())
l = [A, B, C]
ans = list(set(l))
if len(ans) == 2:
    print("Yes")
else:
    print("No")
Problem p02771 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
int mo[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
// int mo[8][2] = { -1,0,1,0,-1,-1,1,1,0,-1,0,1,1,-1,-1,1 };
const int maxn = 1e5 + 10;
int n, m, is, t, ans, p[maxn];
int main() {
#ifdef ONLINE_JUDGE
#else
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(2);
  set<int> q;
  int a;
  for (int i = 0; i < 3; i++)
    cin >> a, q.insert(a);
  if (q.size() == 2)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
  return 0;
  // good job!
}
/*
author: keke
Update log:
2020/2/20 2:46:17  A bug is found...
*/

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
int mo[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
// int mo[8][2] = { -1,0,1,0,-1,-1,1,1,0,-1,0,1,1,-1,-1,1 };
const int maxn = 1e5 + 10;
int n, m, is, t, ans, p[maxn];
int main() {
#ifdef ONLINE_JUDGE
#else
  // freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(2);
  set<int> q;
  int a;
  for (int i = 0; i < 3; i++)
    cin >> a, q.insert(a);
  if (q.size() == 2)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
  return 0;
  // good job!
}
/*
author: keke
Update log:
2020/2/20 2:46:17  A bug is found...
*/
Problem p02771 (Python)

Buggy submission (status: Runtime Error):
nums = list(map(int, input.split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
nums = list(map(int, input().split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")
Problem p02771 (Python)

Buggy submission (status: Runtime Error):
li = list(map(int, input().split()))
if (set(len(li))) == 2:
    print("Yes")
else:
    print("No")


Fixed submission:
li = list(map(int, input().split()))
if (len(set(li))) == 2:
    print("Yes")
else:
    print("No")
Problem p02771 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  map<ll, int> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  auto it = mp.begin();
  while (it != mp.end()) {
    if (it->second == 2) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  map<ll, int> mp;
  mp[a]++;
  mp[b]++;
  mp[c]++;
  auto it = mp.begin();
  while (it != mp.end()) {
    if (it->second == 2) {
      cout << "Yes\n";
      return 0;
    }
    it++;
  }
  cout << "No\n";
  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  ll arr[3], N, flag = 0;
  cin >> N;
  for (ll i = 0; i < N; ++i)
    cin >> arr[i];

  for (int i = 0; i < N; ++i) {
    if (arr[i] % 2 == 0) {
      if (arr[i] % 3 == 0 or arr[i] % 5 == 0)
        continue;
      else {
        flag = 1;
        break;
      }
    }
  }
  if (flag)
    cout << "DENIED";
  else
    cout << "APPROVED";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  ll arr[1000000], N, flag = 0;
  cin >> N;
  for (ll i = 0; i < N; ++i)
    cin >> arr[i];

  for (int i = 0; i < N; ++i) {
    if (arr[i] % 2 == 0) {
      if (arr[i] % 3 == 0 or arr[i] % 5 == 0)
        continue;
      else {
        flag = 1;
        break;
      }
    }
  }
  if (flag)
    cout << "DENIED";
  else
    cout << "APPROVED";

  return 0;
}
Problem p02772 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
arr = [input() for _ in range(n)]
dic = {}
for i in range(n):
    if arr[i] not in dic:
        dic[arr[i]] = 1
    else:
        dic[arr[i]] += 1
largest = max(dic.values())
ans = []
for keys in dic.keys():
    if dic[keys] == largest:
        ans.append(keys)
ans = sorted(ans)
for words in ans:
    print(words)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

for a in A:
    if a % 2 == 1:
        continue
    if a % 3 == 0 or a % 5 == 0:
        continue
    print("DENIED")
    exit()
print("APPROVED")
Problem p02772 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
Ai = input()
Ai = Ai.split(" ")
ans = "APPROVED"
for moji in Ai:
    if moji % 2 != 0:
        pass
    else:
        if (moji % 3 == 0) or (moji % 5 == 0):
            pass
        else:
            ans = "DENIED"
            break
print(ans)


Fixed submission:
N = int(input())
Ai = input()
Ai = Ai.split(" ")
ans = "APPROVED"
for moji in Ai:
    moji = int(moji)
    if moji % 2 != 0:
        pass
    else:
        if (moji % 3 == 0) or (moji % 5 == 0):
            pass
        else:
            ans = "DENIED"
            break
print(ans)
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> b;
  for (int i = 0; i < N; i++) {
    if (a.at(i) % 2 == 0) {
      b.push_back(a.at(i));
    }
  }
  for (int i = 0; i < N; i++) {
    if (b.at(i) % 3 != 0 && b.at(i) % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  vector<int> b;
  for (int i = 0; i < N; i++) {
    if (a.at(i) % 2 == 0) {
      b.push_back(a.at(i));
    }
  }
  for (int i = 0; i < b.size(); i++) {
    if (b.at(i) % 3 != 0 && b.at(i) % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define N 5000005
#define sag (root + root + 1)
#define sol (root + root)
#define ort ((bas + son) / 2)
#define mod 1000000007

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  for (int i = 0; i < n; i++) {
    if (arr[i] % 2 == 0) {
      if (!(arr[i] % 3 == 0 or arr[i] % 5 == 0)) {
        cout << "DENIED" << endl;
        cout << arr[i];
        exit(1);
      }
    }
  }
  cout << "APPROVED";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define N 5000005
#define sag (root + root + 1)
#define sol (root + root)
#define ort ((bas + son) / 2)
#define mod 1000000007

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  for (int i = 0; i < n; i++) {
    if (arr[i] % 2 == 0) {
      if (!(arr[i] % 3 == 0 or arr[i] % 5 == 0)) {
        cout << "DENIED" << endl;
        // cout << arr[i];
        return 0;
      }
    }
  }
  cout << "APPROVED";
  return 0;
}
Problem p02772 (C++)

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

int main() {
  int n;
  vector<int> a(n);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int c = 0;

  for (int i = 0; i < n; i++) {
    if (a.at(i) % 2 == 0) {
      if (a.at(i) % 3 == 0 || a.at(i) % 5 == 0) {
        c++;
      }
    } else {
      c++;
    }
  }

  if (c == n)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  vector<int> a(100);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int c = 0;

  for (int i = 0; i < n; i++) {
    if (a.at(i) % 2 == 0) {
      if (a.at(i) % 3 == 0 || a.at(i) % 5 == 0) {
        c++;
      }
    } else {
      c++;
    }
  }

  if (c == n)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}
Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
int arr[1000];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> arr[i];
  for (int i = 1; i <= n; ++i) {
    if (arr[i] % 2 == 0) {
      if (arr[i] % 3 != 0 && arr[i] % 5 != 0)
        return puts("DENIED");
    }
  }
  puts("APPROVED");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
int arr[1000];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> arr[i];
  for (int i = 1; i <= n; ++i) {
    if (arr[i] % 2 == 0) {
      if (arr[i] % 3 != 0 && arr[i] % 5 != 0)
        return puts("DENIED"), 0;
    }
  }
  puts("APPROVED");
  return 0;
}