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

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

const int MOD = 1e+9 + 7;

// MOD を取りながら nCm を計算する方法
// フェルマーの小定理を使って逆元を使う
template <typename T>
T pow_mod(T n, T p, T m) // (n^p) % m
{
  if (p == 0)
    return 1;
  if (p % 2 == 1)
    return pow_mod<T>(n, p - 1, m) * n % m;
  else {
    T tmp = pow_mod<T>(n, p / 2, m) % m;
    return tmp * tmp % m;
  }
}

// nCk を O(n) で求めるクラス
template <typename T> class Combination {
private:
  int _mod;
  std::vector<T> factorial, factorial_inv;

public:
  Combination(int n, int mod)
      : _mod(mod), factorial(n + 1, 1), factorial_inv(n + 1) {
    for (int i = 1; i <= n; ++i)
      factorial[i] = (i * factorial[i - 1]) % _mod;
    factorial_inv[n] = pow_mod<T>(factorial[n], _mod - 2,
                                  _mod); // 逆元を取る操作は重いので一回のみ行う
    for (int i = n; i >= 1; --i)
      factorial_inv[i - 1] = (i * factorial_inv[i]) % _mod;
  }

  T operator()(int n, int k) {
    if (n < 0 or k > n)
      return 0;
    return factorial[n] * factorial_inv[k] % _mod * factorial_inv[n - k] % _mod;
  }
};

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  int N = S.size();

  long long ans = 0;
  Combination<long long> comb(N + K, MOD);
  FOR(i, N, N + K + 1) {
    ans += comb(i - 1, N - 1) * pow_mod<long long>(25, i - N, MOD) % MOD *
           pow_mod<long long>(26, N + K - i, MOD) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

const int MOD = 1e+9 + 7;

int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;

  int N = S.size();
  vector<vector<long long>> dp(N + K + 1, vector<long long>(N + 1, 0));
  dp[0][0] = 1;
  REP(i, N + K) {
    REP(j, N + 1) {
      if (j == 0)
        dp[i + 1][j] = (25 * dp[i][j]) % MOD;
      if (0 < j and j < N)
        dp[i + 1][j] = (25 * dp[i][j] + dp[i][j - 1]) % MOD;
      if (j == N)
        dp[i + 1][j] = (26 * dp[i][j] + dp[i][j - 1]) % MOD;
    }
  }
  cout << dp[N + K][N] << endl;

  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MOD = 1e9 + 7;

const int MAXN = 2e6 + 100;

int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}

int inv(int x) { return qpow(x, MOD - 2); }

int fact[MAXN];

int comb(int n, int k) {
  return fact[n] * inv(fact[n - k] * fact[k] % MOD) % MOD;
}

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

  fact[0] = 1;
  for (int i = 1; i < MAXN; i++)
    fact[i] = fact[i - 1] * i % MOD;

  int K;
  string S;

  cin >> K >> S;

  int N = S.size();

  int tot = qpow(26, K + N);

  for (int i = 0; i < N; i++) {
    tot = (tot + MOD - comb(N + K, i) * qpow(25, N + K - i) % MOD) % MOD;
  }

  cout << tot << '\\n';

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MOD = 1e9 + 7;

const int MAXN = 1e6 + 100;

int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}

int inv(int x) { return qpow(x, MOD - 2); }

int fact[MAXN];

int comb(int n, int k) {
  return fact[n] * inv(fact[n - k] * fact[k] % MOD) % MOD;
}

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

  fact[0] = 1;
  for (int i = 1; i < MAXN; i++)
    fact[i] = fact[i - 1] * i % MOD;

  int K;
  string S;

  cin >> K >> S;

  int N = S.size();

  int tot = qpow(26, K + N);

  for (int i = 0; i < N; i++) {
    tot = (tot + MOD - comb(N + K, i) * qpow(25, N + K - i) % MOD) % MOD;
  }

  cout << tot << '\\n';

  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007

ll modpow(ll n, ll r) {
  ll res = 1;
  while (r) {
    if (r & 1)
      res = res * n % MOD;
    n = n * n % MOD;
    r >>= 1;
  }
  return res;
}

vector<ll> f(2000100, 1), rf(2000100, 1);
void init() {
  rep(i, 2000000) f[i + 1] = f[i] * (i + 1) % MOD;
  rf[2000000] = modpow(f[2000000], MOD - 2);
  for (int i = 2000000; i > 0; i--)
    rf[i - 1] = rf[i] * i % MOD;
}
ll comb(ll n, ll r) {
  ll res = f[n] * rf[r] % MOD;
  res = res * rf[n - r] % MOD;
  return res;
}

int main() {

  init();
  int k;
  string s;
  cin >> k >> s;
  int size = s.size();
  ll res = 0;
  for (int i = 0; i <= k; i++) {
    ll m = modpow(26, i) * modpow(25, k - i) % MOD;
    m = m * comb(size + k - i - 1, size - 1) % MOD;
    res = (res + m) % MOD;
  }
  cout << res << "\\n";

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007

ll modpow(ll n, ll r) {
  ll res = 1;
  while (r) {
    if (r & 1)
      res = res * n % MOD;
    n = n * n % MOD;
    r >>= 1;
  }
  return res;
}

vector<ll> f(1000100, 1), rf(1000100, 1);
void init() {
  rep(i, 1000000) f[i + 1] = f[i] * (i + 1) % MOD;
  rf[1000000] = modpow(f[1000000], MOD - 2);
  for (int i = 1000000; i > 0; i--)
    rf[i - 1] = rf[i] * i % MOD;
}
ll comb(ll n, ll r) {
  ll res = f[n] * rf[r] % MOD;
  res = res * rf[n - r] % MOD;
  return res;
}

int main() {

  init();
  int k;
  string s;
  cin >> k >> s;
  int size = s.size();
  ll res = 0;
  for (int i = 0; i <= k; i++) {
    ll m = modpow(26, i) * modpow(25, k - i) % MOD;
    m = m * comb(size + k - i - 1, size - 1) % MOD;
    res = (res + m) % MOD;
  }
  cout << res << "\\n";

  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;
const int MAX = 2100000;

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;
}

lint log_mul(lint base, lint bit) {
  lint res = 0;

  while (bit) {
    if (bit & 1)
      res = (res + base) % MOD;
    base = (base + base) % MOD;
    bit >>= 1;
  }

  return res;
}

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  lint k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();

  COMinit();

  lint res = 0;

  for (int x = 0; x <= k; x++) {
    lint t;

    t = COM(n - 1 + k - x, k - x);
    t *= modpow(25, k - x);
    t %= MOD;
    t *= modpow(26, x);
    t %= MOD;

    res += t;
    res %= MOD;
  }

  cout << res << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;
const int MAX = 1100000;

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;
}

lint log_mul(lint base, lint bit) {
  lint res = 0;

  while (bit) {
    if (bit & 1)
      res = (res + base) % MOD;
    base = (base + base) % MOD;
    bit >>= 1;
  }

  return res;
}

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  lint k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();

  COMinit();

  lint res = 0;

  for (int x = 0; x <= k; x++) {
    lint t;

    t = COM(n - 1 + k - x, k - x);
    t *= modpow(25, k - x);
    t %= MOD;
    t *= modpow(26, x);
    t %= MOD;

    res += t;
    res %= MOD;
  }

  cout << res << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
ll fp(ll b, ll e) {
  ll rs = 1ll;
  for (; e > 0; e /= 2, b = (b * b) % mod)
    if (e % 2 == 1)
      rs = (rs * b) % mod;
  return rs;
}
ll fc[2000005], iv[2000005];
ll c(int i, int j) {
  ll res = (fc[i] * iv[j]) % mod;
  res = (res * iv[i - j]) % mod;
  return res;
}
int32_t main() {
  fc[0] = 1ll;
  for (int i = 1; i < 2000005; i++)
    fc[i] = (fc[i - 1] * i) % mod;
  iv[2000004] = fp(fc[2000004], mod - 2);
  for (int i = 2000003; i >= 0; i--)
    iv[i] = (iv[i + 1] * (i + 1)) % mod;
  int k, n;
  cin >> k;
  string s;
  cin >> s;
  n = s.size();
  ll ans = 0ll;
  for (int i = n; i <= k + n; i++)
    (ans += (c(k + n, i) * fp(25, k + n - i))) %= mod;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
ll fp(ll b, ll e) {
  ll rs = 1ll;
  for (; e > 0; e /= 2, b = (b * b) % mod)
    if (e % 2 == 1)
      rs = (rs * b) % mod;
  return rs;
}
ll fc[1000005], iv[1000005];
ll c(int i, int j) {
  ll res = (fc[i] * iv[j]) % mod;
  res = (res * iv[i - j]) % mod;
  return res;
}
int32_t main() {
  fc[0] = 1ll;
  for (int i = 1; i < 1000005; i++)
    fc[i] = (fc[i - 1] * i) % mod;
  iv[1000004] = fp(fc[1000004], mod - 2);
  for (int i = 1000003; i >= 0; i--)
    iv[i] = (iv[i + 1] * (i + 1)) % mod;
  int k, n;
  cin >> k;
  string s;
  cin >> s;
  n = s.size();
  ll ans = 0ll;
  for (int i = n; i <= k + n; i++)
    (ans += (c(k + n, i) * fp(25, k + n - i))) %= mod;
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e6 + 555;
const int MOD = 1e9 + 7;
ll xpow(ll a, ll b) {
  ll ret = 1;
  a %= MOD;
  assert(b >= 0);
  while (b) {
    if (b & 1)
      ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  static ll inv[maxn + 555], invp[maxn + 555], p[maxn + 555];
  inv[1] = 1;
  for (int i = 2; i <= maxn; i++)
    inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
  p[0] = 1;
  for (int i = 1; i <= maxn; i++)
    p[i] = p[i - 1] * i % MOD;
  invp[0] = 1;
  for (int i = 1; i <= maxn; i++)
    invp[i] = invp[i - 1] * inv[i] % MOD;
  auto C = [&](int a, int b) -> ll {
    if (a < b)
      return 0;
    else
      return p[a] * invp[b] % MOD * invp[a - b] % MOD;
  };
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  int tot = n + (int)s.size();
  for (int i = (int)s.size(); i <= tot; i++) {
    // 枚举放i个a，剩下地方放b..z
    (ans += C(tot, i) * xpow(25, tot - i)) %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
ll xpow(ll a, ll b) {
  ll ret = 1;
  a %= MOD;
  assert(b >= 0);
  while (b) {
    if (b & 1)
      ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  static ll inv[maxn + 555], invp[maxn + 555], p[maxn + 555];
  inv[1] = 1;
  for (int i = 2; i <= maxn; i++)
    inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
  p[0] = 1;
  for (int i = 1; i <= maxn; i++)
    p[i] = p[i - 1] * i % MOD;
  invp[0] = 1;
  for (int i = 1; i <= maxn; i++)
    invp[i] = invp[i - 1] * inv[i] % MOD;
  auto C = [&](int a, int b) -> ll {
    if (a < b)
      return 0;
    else
      return p[a] * invp[b] % MOD * invp[a - b] % MOD;
  };
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  int tot = n + (int)s.size();
  for (int i = (int)s.size(); i <= tot; i++) {
    // 枚举放i个a，剩下地方放b..z
    (ans += C(tot, i) * xpow(25, tot - i)) %= MOD;
  }
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using PP = pair<int, pair<int, int>>;
using T = tuple<string, int, int>;
const string EMP = " ";
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll memo1[2020200], memo2[2020200];

ll B(ll x) {
  ll res = 1, k = MOD - 2, y = x;
  while (k) {
    if (k & 1) {
      res *= y;
      res %= MOD;
    }
    y *= y;
    y %= MOD;
    k >>= 1;
  }
  return res;
}

void init() {
  memo1[0] = 1;
  for (ll i = 1; i < 2020200; i++)
    memo1[i] = (memo1[i - 1] * i) % MOD;
  for (ll i = 0; i < 2020200; i++)
    memo2[i] = B(memo1[i]);
}

ll C(ll n, ll r) {
  ll a = memo1[n];
  ll b = memo2[r];
  ll c = memo2[n - r];
  ll res = a * b;
  res %= MOD;
  res *= c;
  res %= MOD;
  return res;
}

ll BB(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1) {
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    y >>= 1;
  }
  return res;
}
int main() {
  ll k, n;
  string s;
  cin >> k >> s;
  n = s.size();
  init();
  ll ans = 0, now = 0;
  for (ll i = 0; i <= k; i++) {
    now = BB(25, i);
    now %= MOD;
    now *= BB(26, k - i);
    now %= MOD;
    now *= C(i + n - 1, n - 1);
    now %= MOD;
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using PP = pair<int, pair<int, int>>;
using T = tuple<string, int, int>;
const string EMP = " ";
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll memo1[202020], memo2[202020];

ll B(ll x) {
  ll res = 1, k = MOD - 2, y = x;
  while (k) {
    if (k & 1) {
      res *= y;
      res %= MOD;
    }
    y *= y;
    y %= MOD;
    k >>= 1;
  }
  return res;
}

void init(int n) {
  memo1[0] = 1;
  for (ll i = 1; i < 202020; i++)
    memo1[i] = (memo1[i - 1] * i) % MOD;
  for (ll i = 0; i < 202020; i++)
    memo2[i] = B(memo1[i]);
}

ll C(ll n, ll r) {
  ll a = memo1[n];
  ll b = memo2[r];
  ll c = memo2[n - r];
  ll res = a * b;
  res %= MOD;
  res *= c;
  res %= MOD;
  return res;
}

ll BB(ll x, ll y) {
  ll res = 1;
  while (y) {
    if (y & 1) {
      res *= x;
      res %= MOD;
    }
    x *= x;
    x %= MOD;
    y >>= 1;
  }
  return res;
}
int main() {
  ll k, n;
  string s;
  cin >> k >> s;
  n = s.size();
  init(k + n);
  ll ans = 0, now = 0;
  for (ll i = 0; i <= k; i++) {
    now = BB(25, i);
    now %= MOD;
    now *= BB(26, k - i);
    now %= MOD;
    now *= C(i + n - 1, n - 1);
    now %= MOD;
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

// Problem Link:
// Tutorial Link:

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL, LL>
#define ff first
#define ss second
#define rep(i, a, b) for (LL i = a; i <= b; ++i)
#define repb(i, a, b) for (LL i = a; i >= b; --i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld, ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL poww(LL a, LL n) {
  if (n == 0)
    return 1;
  LL val = poww(a, n / 2);
  if (n % 2 == 0)
    return (val * val) % mod;
  else
    return (((val * val) % mod) * a) % mod;
}

LL k, n, fact[3000005], inv[3000005];
string s;

inline LL comb(LL n, LL k) {
  if (n == 0 || k == 0 || n - k < 0)
    return 1;
  return (((fact[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

int main() {
  FIO;
  cin >> k >> s;
  fact[0] = 1;
  inv[0] = 1;
  n = s.length();
  rep(i, 1, n + k + 2) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv[i] = poww(fact[i], mod - 2);
  }
  LL ans = poww(26LL, n + k);
  rep(i, 0, n - 1) {
    LL val = comb(n + k, i);
    val = (val * poww(25, n + k - i)) % mod;
    ans = (ans + mod - val) % mod;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

// Problem Link:
// Tutorial Link:

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL, LL>
#define ff first
#define ss second
#define rep(i, a, b) for (LL i = a; i <= b; ++i)
#define repb(i, a, b) for (LL i = a; i >= b; --i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld, ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL poww(LL a, LL n) {
  if (n == 0)
    return 1;
  LL val = poww(a, n / 2);
  if (n % 2 == 0)
    return (val * val) % mod;
  else
    return (((val * val) % mod) * a) % mod;
}

LL k, n, fact[1000005], inv[1000005];
string s;

inline LL comb(LL n, LL k) {
  if (n == 0 || k == 0 || n - k < 0)
    return 1;
  return (((fact[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

int main() {
  FIO;
  cin >> k >> s;
  fact[0] = 1;
  inv[0] = 1;
  n = s.length();
  rep(i, 1, n + k + 2) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv[i] = poww(fact[i], mod - 2);
  }
  LL ans = poww(26LL, n + k);
  rep(i, 0, n - 1) {
    LL val = comb(n + k, i);
    val = (val * poww(25, n + k - i)) % mod;
    ans = (ans + mod - val) % mod;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fo(i, a, b) for ((i) = (a); i <= (b); i++)
#define rfo(i, a, b) for ((i) = (a); i >= (b); i--)
#define inrange(x, y, z) (((x) >= (y)) && ((x) <= (z)))
#define ALL(vec) ((vec).begin(), (vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)), (vec).end())
using namespace std;
int k, n, l;
long long res, MOD = 1000000007, p25[2000100];
long long inv[2000100], fac[2000100], ifac[2000100];
void init_math(int N) {
  inv[1] = 1LL;
  for (int i = 2; i <= N; i++)
    inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD);
  fac[0] = 1LL;
  ifac[0] = 1LL;
  for (int i = 1; i <= N; i++) {
    fac[i] = (fac[i - 1] * (long long)(i)) % MOD;
    ifac[i] = (ifac[i - 1] * inv[i]) % MOD;
  }
}
long long C(int x, int y) {
  return ((fac[x] * ifac[y]) % MOD * ifac[x - y]) % MOD;
}
string s;
int main() {
#ifdef FILIN
#ifndef DavidDesktop
  freopen(FILIN, "r", stdin);
  freopen(FILOUT, "w", stdout);
#endif
#endif
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> s;
  n = s.size() + k;
  l = s.size();
  init_math(n);
  p25[0] = 1;
  for (int x = 1; x <= n; x++) {
    p25[x] = (p25[x - 1] * 25LL) % MOD;
  }
  for (int x = l; x <= n; x++) {
    res = (res + C(n, x) * p25[n - x] % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fo(i, a, b) for ((i) = (a); i <= (b); i++)
#define rfo(i, a, b) for ((i) = (a); i >= (b); i--)
#define inrange(x, y, z) (((x) >= (y)) && ((x) <= (z)))
#define ALL(vec) ((vec).begin(), (vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)), (vec).end())
using namespace std;
int k, n, l;
long long res, MOD = 1000000007, p25[1000100];
long long inv[1000100], fac[1000100], ifac[1000100];
void init_math(int N) {
  inv[1] = 1LL;
  for (int i = 2; i <= N; i++)
    inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD);
  fac[0] = 1LL;
  ifac[0] = 1LL;
  for (int i = 1; i <= N; i++) {
    fac[i] = (fac[i - 1] * (long long)(i)) % MOD;
    ifac[i] = (ifac[i - 1] * inv[i]) % MOD;
  }
}
long long C(int x, int y) {
  return ((fac[x] * ifac[y]) % MOD * ifac[x - y]) % MOD;
}
string s;
int main() {
#ifdef FILIN
#ifndef DavidDesktop
  freopen(FILIN, "r", stdin);
  freopen(FILOUT, "w", stdout);
#endif
#endif
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> s;
  n = s.size() + k;
  l = s.size();
  init_math(n);
  p25[0] = 1;
  for (int x = 1; x <= n; x++) {
    p25[x] = (p25[x - 1] * 25LL) % MOD;
  }
  for (int x = l; x <= n; x++) {
    res = (res + C(n, x) * p25[n - x] % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int k, n, l;
long long res, MOD = 1000000007, p25[2000100], comb;
long long inv[2000100];
void init_math(int N) {
  inv[1] = 1LL;
  for (int i = 2; i <= N; i++)
    inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD);
}
string s;
int main() {
  cin >> k >> s;
  n = s.size() + k;
  l = s.size();
  init_math(n);
  p25[0] = 1;
  for (int x = 1; x <= n; x++)
    p25[x] = (p25[x - 1] * 25LL) % MOD;
  comb = 1;
  for (int x = 1; x <= n; x++) {
    comb = (comb * (long long)(n - x + 1)) % MOD;
    comb = (comb * inv[x]) % MOD;
    if (x >= l)
      res = (res + comb * p25[n - x] % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int k, n, l;
long long res, MOD = 1000000007, p25[1000100], comb;
long long inv[1000100];
void init_math(int N) {
  inv[1] = 1LL;
  for (int i = 2; i <= N; i++)
    inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD);
}
string s;
int main() {
  cin >> k >> s;
  n = s.size() + k;
  l = s.size();
  init_math(n);
  p25[0] = 1;
  for (int x = 1; x <= n; x++)
    p25[x] = (p25[x - 1] * 25LL) % MOD;
  comb = 1;
  for (int x = 1; x <= n; x++) {
    comb = (comb * (long long)(n - x + 1)) % MOD;
    comb = (comb * inv[x]) % MOD;
    if (x >= l)
      res = (res + comb * p25[n - x] % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}