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

#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const int MAXN = 2e6 + 10;
ll fact[MAXN];
ll powd[MAXN];
ll b_pow(ll x, ll m) {
  if (m == 1LL)
    return x % MOD;
  if (m == 0LL)
    return 1LL;
  if (m % 2LL == 0LL) {
    return b_pow((x * x) % MOD, m / 2LL) % MOD;
  } else {
    return (x * b_pow((x * x) % MOD, m / 2LL)) % MOD;
  }
}

ll inverse(ll x) {
  if (x == 0)
    return 1LL;
  return b_pow(x, MOD - 2) % MOD;
}
ll nCk(ll n, ll k) {
  if (n < k)
    return 0LL;
  return (((fact[n] % MOD) * inverse(fact[n - k])) % MOD * inverse(fact[k])) %
         MOD;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fact[0] = 1;
  powd[0] = 1;
  for (ll i = 1; i < MAXN - 1; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
    powd[i] = powd[i - 1] * 25;
    powd[i] %= MOD;
  }

  ll n;
  cin >> n;
  string S;
  cin >> S;
  ll k = S.size();
  ll r = 0;
  n += k;
  for (int j = 0; j <= n - k; j++) {
    // db(nCk(n, j + k)*powd[n - k - j]);
    r += nCk(n, j + k) * powd[n - k - j];
    r %= MOD;
  }
  cout << r << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;
ll fact[MAXN];
ll powd[MAXN];
ll b_pow(ll x, ll m) {
  if (m == 1LL)
    return x % MOD;
  if (m == 0LL)
    return 1LL;
  if (m % 2LL == 0LL) {
    return b_pow((x * x) % MOD, m / 2LL) % MOD;
  } else {
    return (x * b_pow((x * x) % MOD, m / 2LL)) % MOD;
  }
}

ll inverse(ll x) {
  if (x == 0)
    return 1LL;
  return b_pow(x, MOD - 2) % MOD;
}
ll nCk(ll n, ll k) {
  if (n < k)
    return 0LL;
  return (((fact[n] % MOD) * inverse(fact[n - k])) % MOD * inverse(fact[k])) %
         MOD;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fact[0] = 1;
  powd[0] = 1;
  for (ll i = 1; i < MAXN - 1; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
    powd[i] = powd[i - 1] * 25;
    powd[i] %= MOD;
  }

  ll n;
  cin >> n;
  string S;
  cin >> S;
  ll k = S.size();
  ll r = 0;
  n += k;
  for (int j = 0; j <= n - k; j++) {
    // db(nCk(n, j + k)*powd[n - k - j]);
    r += nCk(n, j + k) * powd[n - k - j];
    r %= MOD;
  }
  cout << r << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v)                                                          \\
  for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

const ll MAX = 2000001;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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() {
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll N = S.size();
  COMinit();

  vector<ll> p25(K + 1), p26(K + 1);
  p25[0] = 1;
  p26[0] = 1;
  REP(i, K) {
    p25[i + 1] = (p25[i] * 25) % MOD;
    p26[i + 1] = (p26[i] * 26) % MOD;
  }
  ll ans = 0;
  REP(i, K + 1) {
    ll t;
    t = (p25[K - i] * p26[i]) % MOD;
    t = (t * (COM(K - i + N - 1, N - 1))) % MOD;
    ans = (ans + t) % MOD;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define REPV(iter, v)                                                          \\
  for (auto(iter) = (v).begin(); (iter) != (v).end(); ++(iter))
#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

const ll MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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() {
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll N = S.size();
  COMinit();

  vector<ll> p25(K + 1), p26(K + 1);
  p25[0] = 1;
  p26[0] = 1;
  REP(i, K) {
    p25[i + 1] = (p25[i] * 25) % MOD;
    p26[i + 1] = (p26[i] * 26) % MOD;
  }
  ll ans = 0;
  REP(i, K + 1) {
    ll t;
    t = (p25[K - i] * p26[i]) % MOD;
    t = (t * (COM(K - i + N - 1, N - 1))) % MOD;
    ans = (ans + t) % MOD;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 22, mod = 1e9 + 7;
int fact[maxn], inv[maxn];
void pre() {
  for (int i = 0; i < maxn; i++)
    if (i < 2)
      fact[i] = inv[i] = 1;
    else
      fact[i] = i, inv[i] = mod - (mod / i) * 1ll * inv[mod % i] % mod;
  for (int i = 1; i < maxn; i++)
    fact[i] = fact[i] * 1ll * fact[i - 1] % mod,
    inv[i] = inv[i] * 1ll * inv[i - 1] % mod;
}
int bp(int a, int p) {
  int r = 1;
  while (p) {
    if (p & 1)
      r = r * 1ll * a % mod;
    a = a * 1ll * a % mod, p >>= 1;
  }
  return r;
}
int nck(int i, int j) {
  if (i < j || j < 0)
    return 0;
  int t = fact[i] * 1ll * inv[j] % mod;
  return t * 1ll * inv[i - j] % mod;
}
int get(int i, int j) {
  int t = bp(25, i - j);
  return t * 1ll * nck(i, j) % mod;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  pre();
  int ans = 0, n, k;
  string s;
  cin >> k >> s;
  n = s.size();
  for (int i = n; i <= n + k; i++)
    ans = (ans + get(n + k, i)) % mod;
  cout << ans;
  return 0;
}
// cacyaa
// 128 + 2 + 128*


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 20, mod = 1e9 + 7;
int fact[maxn], inv[maxn];
void pre() {
  for (int i = 0; i < maxn; i++)
    if (i < 2)
      fact[i] = inv[i] = 1;
    else
      fact[i] = i, inv[i] = mod - (mod / i) * 1ll * inv[mod % i] % mod;
  for (int i = 1; i < maxn; i++)
    fact[i] = fact[i] * 1ll * fact[i - 1] % mod,
    inv[i] = inv[i] * 1ll * inv[i - 1] % mod;
}
int bp(int a, int p) {
  int r = 1;
  while (p) {
    if (p & 1)
      r = r * 1ll * a % mod;
    a = a * 1ll * a % mod, p >>= 1;
  }
  return r;
}
int nck(int i, int j) {
  if (i < j || j < 0)
    return 0;
  int t = fact[i] * 1ll * inv[j] % mod;
  return t * 1ll * inv[i - j] % mod;
}
int get(int i, int j) {
  int t = bp(25, i - j);
  return t * 1ll * nck(i, j) % mod;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  pre();
  int ans = 0, n, k;
  string s;
  cin >> k >> s;
  n = s.size();
  for (int i = n; i <= n + k; i++)
    ans = (ans + get(n + k, i)) % mod;
  cout << ans;
  return 0;
}
// cacyaa
// 128 + 2 + 128*
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long int;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define MOD 1000000007LL

ll pow(ll n, ll k) {
  ll r = 1;

  while (k > 0) {
    if (k % 2 == 1) {
      r = r * n % MOD;
    }
    n = n * n % MOD;
    k /= 2;
  }
  return r;
}

ll fac[3000000];

ll inv(ll x) { return pow(x, MOD - 2); }

ll C(ll n, ll k) {
  if (k > 0) {
    return fac[n] * inv(fac[n - k]) % MOD * inv(fac[k]) % MOD;
  } else {
    return 1;
  }
}

void solve(ll k, ll n) {
  ll ans = 0;
  rep(i, k + 1) {
    ll c = C(i + n - 1, n - 1);
    ll p25 = pow(25, i);
    ll p26 = pow(26, k - i);
    ll tmp = p25 * c % MOD * p26 % MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll K;
  string S;
  ll N;
  cin >> K >> S;
  N = S.size();

  fac[0] = 1;
  ll f = 1;
  for (ll i = 1; i < 3000000; i++) {
    f *= i;
    f %= MOD;
    fac[i] = f;
  }

  solve(K, N);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long int;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define MOD 1000000007LL

ll pow(ll n, ll k) {
  ll r = 1;

  while (k > 0) {
    if (k % 2 == 1) {
      r = r * n % MOD;
    }
    n = n * n % MOD;
    k /= 2;
  }
  return r;
}

ll fac[1000000];

ll inv(ll x) { return pow(x, MOD - 2); }

ll C(ll n, ll k) {
  if (k > 0) {
    return fac[n] * inv(fac[n - k]) % MOD * inv(fac[k]) % MOD;
  } else {
    return 1;
  }
}

void solve(ll k, ll n) {
  ll ans = 0;
  rep(i, k + 1) {
    ll c = C(i + n - 1, n - 1);
    ll p25 = pow(25, i);
    ll p26 = pow(26, k - i);
    ll tmp = p25 * c % MOD * p26 % MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll K;
  string S;
  ll N;
  cin >> K >> S;
  N = S.size();

  fac[0] = 1;
  ll f = 1;
  for (ll i = 1; i < 1000000; i++) {
    f *= i;
    f %= MOD;
    fac[i] = f;
  }

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


// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a) + 1)
#define fi first
#define se second
#define pb push_back

#define ll long long
#define pii pair<int, int>
// #define int ll
const int MOD = 1000000007;
int fac[2000006], ifac[2000006], inv[2000006];

int ncr(int n, int r) {
  return 1ll * fac[n] * ifac[r] % MOD * ifac[n - r] % MOD;
}

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

int dp[20][20];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac[0] = ifac[0] = fac[1] = ifac[1] = inv[0] = inv[1] = 1;
  iter(i, 2, 2000004) {
    inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD;
    fac[i] = 1ll * fac[i - 1] * i % MOD;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % MOD;
  }
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  iter(i, s.length(), n + s.length() + 1) ans =
      (ans + 1ll * qpow(25, n + s.length() - i) * ncr(n + s.length(), i)) % MOD;
  cout << ans << endl;
}


Error: 0

Fixed submission:


// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a) + 1)
#define fi first
#define se second
#define pb push_back

#define ll long long
#define pii pair<int, int>
// #define int ll
const int MOD = 1000000007;
int fac[1000006], ifac[1000006], inv[1000006];

int ncr(int n, int r) {
  return 1ll * fac[n] * ifac[r] % MOD * ifac[n - r] % MOD;
}

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

int dp[20][20];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac[0] = ifac[0] = fac[1] = ifac[1] = inv[0] = inv[1] = 1;
  iter(i, 2, 1000004) {
    inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD;
    fac[i] = 1ll * fac[i - 1] * i % MOD;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % MOD;
  }
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  iter(i, s.length(), n + s.length() + 1) ans =
      (ans + 1ll * qpow(25, n + s.length() - i) * ncr(n + s.length(), i)) % MOD;
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

int main() {
  int k;
  string s;
  cin >> k >> s;

  int n = s.size();

  ll f[n + k + 1];
  f[0] = 1;
  rep(i, n + k) { f[i + 1] = (i + 1) * f[i] % mod; }

  ll fi[n + k + 1];
  rep(i, n + k + 1) fi[i] = modpow(f[i], mod - 2);

  auto choose = [&](ll x, ll y) {
    return (f[x] * fi[y] % mod) * fi[x - y] % mod;
  };

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = modpow(26, k - i);
    now = now * modpow(25, i) % mod;
    now = now * choose(n - 1 + i, n - 1) % mod;
    ans = (ans + now) % mod;
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

ll choose(ll n, ll k) {
  ll x = 1, y = 1;
  rep(i, k) {
    x = x * (n - i) % mod;
    y = y * (i + 1) % mod;
  }
  return x * modpow(y, mod - 2) % mod;
}

int main() {
  int k;
  string s;
  cin >> k >> s;

  int n = s.size();
  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = modpow(26, k - i);
    now = now * modpow(25, i) % mod;
    now *= choose(n - 1 + i, n - 1);
    ans = (ans + now) % 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;
/*
26文字はいるんだけど、重複組み合わせをのぞく
26^Kからどっか固定してると考える
aaaaaaaa
~
zzzzzzzz

aaaaaoof
~
zzzzzoofまで
でもない

aaaaaoogはNG
aaaaoaof
aaaoaaof


*/

const int MAX = 2e6 + 10;
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;
  }
}

ll 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() {
  COMinit();
  ll K, oo = 2e6 + 10, ans = 0;
  cin >> K;
  string S;
  cin >> S;
  ll ssz = S.size();
  vector<ll> Z25(oo, 0), Z26(oo, 0);
  Z25[0] = 1;
  Z26[0] = 1;
  for (ll i = 0; i < oo; i++)
    Z25[i + 1] = (Z25[i] * 25) % MOD;
  for (ll i = 0; i < oo; i++)
    Z26[i + 1] = (Z26[i] * 26) % MOD;
  for (ll i = 0; i <= K; i++) {
    ll n = COM(ssz + i - 1, i);
    (n *= Z25[i]) %= MOD;
    (n *= Z26[K - i]) %= MOD;
    (ans += n) %= MOD;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*
26文字はいるんだけど、重複組み合わせをのぞく
26^Kからどっか固定してると考える
aaaaaaaa
~
zzzzzzzz

aaaaaoof
~
zzzzzoofまで
でもない

aaaaaoogはNG
aaaaoaof
aaaoaaof


*/

const int MAX = 1e6 + 10;
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;
  }
}

ll 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() {
  COMinit();
  ll K, oo = 1e6 + 10, ans = 0;
  cin >> K;
  string S;
  cin >> S;
  ll ssz = S.size();
  vector<ll> Z25(oo, 0), Z26(oo, 0);
  Z25[0] = 1;
  Z26[0] = 1;
  for (ll i = 0; i < oo; i++)
    Z25[i + 1] = (Z25[i] * 25) % MOD;
  for (ll i = 0; i < oo; i++)
    Z26[i + 1] = (Z26[i] * 26) % MOD;
  for (ll i = 0; i <= K; i++) {
    ll n = COM(ssz + i - 1, i);
    (n *= Z25[i]) %= MOD;
    (n *= Z26[K - i]) %= MOD;
    (ans += n) %= MOD;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define pb push_back
#define pq priority_queue
#define pii pair<int, int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr << #x << "=" << x << '\\n'
#define rep(i, a, b) for (int i = a; i < (b); i++)

const int maxn = 3e6 + 10;

int n, m;
ll fac[maxn];

ll p0w(ll base, int p) {
  ll res = 1;
  while (p) {
    if (p % 2 == 1)
      res *= base, res %= mod;
    base = base * base % mod;
    p >>= 1;
  }
  return res;
}

ll C(int x, int y) {
  return fac[x] * p0w(fac[x - y], mod - 2) % mod * p0w(fac[y], mod - 2) % mod;
}

int main() {
  std::ios::sync_with_stdio(false);
  fac[0] = 1;
  rep(i, 1, maxn) fac[i] = fac[i - 1] * (ll)i % mod;
  cin >> n;
  string s;
  cin >> s;
  n += SZ(s);
  int m = SZ(s);
  ll ans = 0;
  for (int i = m; i <= n; i++) {
    ans += C(i - 1, m - 1) * p0w(25, i - m) % mod * p0w(26, n - i) % mod;
    ans %= mod;
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define pb push_back
#define pq priority_queue
#define pii pair<int, int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr << #x << "=" << x << '\\n'
#define rep(i, a, b) for (int i = a; i < (b); i++)

const int maxn = 1e6 + 10;

int n, m;
ll fac[maxn];

ll p0w(ll base, int p) {
  ll res = 1;
  while (p) {
    if (p % 2 == 1)
      res *= base, res %= mod;
    base = base * base % mod;
    p >>= 1;
  }
  return res;
}

ll C(int x, int y) {
  return fac[x] * p0w(fac[x - y], mod - 2) % mod * p0w(fac[y], mod - 2) % mod;
}

int main() {
  std::ios::sync_with_stdio(false);
  fac[0] = 1;
  rep(i, 1, maxn) fac[i] = fac[i - 1] * (ll)i % mod;
  cin >> n;
  string s;
  cin >> s;
  n += SZ(s);
  int m = SZ(s);
  ll ans = 0;
  for (int i = m; i <= n; i++) {
    ans += C(i - 1, m - 1) * p0w(25, i - m) % mod * p0w(26, n - i) % mod;
    ans %= mod;
  }
  cout << ans;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int k;
string s;
const int N = 1e6 * 2 + 10;
ll fac[N];
ll inv[N];

ll power(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

void init() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = fac[i - 1] * i % mod;
  }
  inv[N - 1] = power(fac[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; --i) {
    inv[i] = inv[i + 1] * (i + 1) % mod;
  }
}

ll C(ll a, ll b) { return fac[a] * inv[b] % mod * inv[a - b] % mod; }

int main() {
  init();
  cin >> k >> s;
  int n = s.length();
  ll res = 0;
  ll sum = k + n;
  for (int i = 0; i <= k; ++i) {
    res = (res + power(26, i) * C(sum - 1 - i, n - 1) % mod * power(25, k - i) %
                     mod) %
          mod;
  }
  cout << res << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int mod = 1e9 + 7;
int k;
string s;
const int N = 1e6 + 1;
ll fac[N];
ll inv[N];

ll power(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

void init() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = fac[i - 1] * i % mod;
  }
  inv[N - 1] = power(fac[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; --i) {
    inv[i] = inv[i + 1] * (i + 1) % mod;
  }
}

ll C(ll a, ll b) { return fac[a] * inv[b] % mod * inv[a - b] % mod; }

int main() {
  init();
  cin >> k >> s;
  int n = s.length();
  ll res = 0;
  ll sum = k + n;
  for (int i = 0; i <= k; ++i) {
    res = (res + power(26, i) * C(sum - 1 - i, n - 1) % mod * power(25, k - i) %
                     mod) %
          mod;
  }
  cout << res << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define fod(i, a, b) for (int i = a; i >= b; i--)
#define me0(a) memset(a, 0, sizeof(a))
#define me1(a) memset(a, -1, sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long ll;
void read(int &val) {
  int x = 0;
  int bz = 1;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    bz = -1;
    c = getchar();
  }
  for (; c >= '0' && c <= '9'; c = getchar())
    x = x * 10 + c - 48;
  val = x * bz;
}
const int mod = 1e9 + 7;
const int maxn = 2e6 + 11;
ll fct[maxn], ans;
int n, k;
char s[maxn];

ll qmi(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
ll C(ll a, ll b) {
  if (a < b)
    return 0;
  return fct[a] * qmi(fct[b], mod - 2) % mod * qmi(fct[a - b], mod - 2) % mod;
}
void init() {
  fct[0] = 1;
  fo(i, 1, maxn - 1) fct[i] = fct[i - 1] * i % mod;
}
int main() {
  init();
  read(k);
  scanf("%s", s);
  int len = strlen(s);
  n = len + k;
  ans = 0;
  fo(i, len, n) {
    ll t = (C(i - 1, len - 1) * qmi(25, i - len) % mod * qmi(26, n - i) % mod) %
           mod;
    ans = ((ans + t) % mod + mod) % mod;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define fod(i, a, b) for (int i = a; i >= b; i--)
#define me0(a) memset(a, 0, sizeof(a))
#define me1(a) memset(a, -1, sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ULL;
typedef long long ll;
void read(int &val) {
  int x = 0;
  int bz = 1;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    bz = -1;
    c = getchar();
  }
  for (; c >= '0' && c <= '9'; c = getchar())
    x = x * 10 + c - 48;
  val = x * bz;
}
const int mod = 1e9 + 7;
const int maxn = 1e6 + 11;
ll fct[maxn], k, ans, n;
string s;

ll qmi(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
ll C(ll a, ll b) {
  if (a < b)
    return 0;
  return fct[a] * qmi(fct[b], mod - 2) % mod * qmi(fct[a - b], mod - 2) % mod;
}
void init() {
  fct[0] = 1;
  fo(i, 1, maxn - 1) fct[i] = fct[i - 1] * i % mod;
}
int main() {
  init();

  cin >> k;
  cin >> s;
  int len = s.size();
  n = len + k;
  ans = 0;
  fo(i, len, n) {
    ll t = (C(i - 1, len - 1) * qmi(25, i - len) % mod * qmi(26, n - i) % mod) %
           mod;
    ans = ((ans + t) % mod + mod) % mod;
  }
  cout << ans << endl;
  return 0;
}