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

#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

const ll com_max = 2000000;
ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for (ll i = 2; i < com_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;
}
ll rep_square(ll a, ll b) {
  // return a^b
  ll ans = 1;
  ll base = a;
  while (b != 0) {
    if (b & 1) {
      ans *= base;
      ans %= mod;
    }
    base *= base;
    base %= mod;
    b >>= 1;
  }
  return ans;
}

int main() {
  com_init();
  ll k;
  string s;
  cin >> k >> s;
  ll n = s.length();
  ll ans = 0;

  rep(i, k + 1) {
    ll temp = com(n + k - i - 1, n - 1);

    temp *= rep_square(26, i);
    temp %= mod;

    temp *= rep_square(25, k - i);
    temp %= mod;

    ans += temp;
    ans %= mod;
  }

  cout << ans << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

const ll com_max = 510000;
ll fac[com_max], inv[com_max], finv[com_max];

void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for (ll i = 2; i < com_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;
}
ll rep_square(ll a, ll b) {
  // return a^b
  ll ans = 1;
  ll base = a;
  while (b != 0) {
    if (b & 1) {
      ans *= base;
      ans %= mod;
    }
    base *= base;
    base %= mod;
    b >>= 1;
  }
  return ans;
}

int main() {
  com_init();
  ll k;
  string s;
  cin >> k >> s;
  ll n = s.length();
  ll ans = 0;

  rep(i, k + 1) {
    ll temp = com(n + k - i - 1, n - 1);

    /*
    temp *= rep_square(26, i);
    temp %= mod;

    temp *= rep_square(25, k - i);
    temp %= mod;
    */

    ans += temp;
    ans %= mod;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define N 2000010
#define Mod 1000000007
char s[N];
int fac[N], inv[N];
inline void init(int n) {
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1LL * fac[i - 1] * i % Mod;
  for (int i = 2; i <= n; i++)
    inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod;
  for (int i = 2; i <= n; i++)
    inv[i] = 1LL * inv[i - 1] * inv[i] % Mod;
}
inline int Pow(int a, int b, int p = Mod) {
  int res = 1;
  for (; b; b >>= 1, a = 1LL * a * a % p)
    if (b & 1)
      res = 1LL * res * a % p;
  return res;
}
inline int C(int n, int m) {
  return 1LL * fac[n] * inv[m] % Mod * inv[n - m] % Mod;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch))
    ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int main() {
  int n = read();
  scanf("%s", s);
  int m = strlen(s), ans = 0;
  n += m;
  init(n);
  for (int i = m; i <= n; i++)
    (ans += 1LL * Pow(25, i - m) * Pow(26, n - i) % Mod * C(i - 1, m - 1) %
            Mod) %= Mod;
  return printf("%d\\n", ans), 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define N 1000010
#define Mod 1000000007
char s[N];
int fac[N], inv[N];
inline void init(int n) {
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1LL * fac[i - 1] * i % Mod;
  for (int i = 2; i <= n; i++)
    inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod;
  for (int i = 2; i <= n; i++)
    inv[i] = 1LL * inv[i - 1] * inv[i] % Mod;
}
inline int Pow(int a, int b, int p = Mod) {
  int res = 1;
  for (; b; b >>= 1, a = 1LL * a * a % p)
    if (b & 1)
      res = 1LL * res * a % p;
  return res;
}
inline int C(int n, int m) {
  return 1LL * fac[n] * inv[m] % Mod * inv[n - m] % Mod;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch))
    ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int main() {
  int n = read();
  scanf("%s", s);
  int m = strlen(s), ans = 0;
  n += m;
  init(n);
  for (int i = m; i <= n; i++)
    (ans += 1LL * Pow(25, i - m) * Pow(26, n - i) % Mod * C(i - 1, m - 1) %
            Mod) %= Mod;
  return printf("%d\\n", ans), 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string>
#define ll long long

using namespace std;

const ll mod = 1000000007;
const ll maxn = 2000005;
ll fun[maxn];
ll infun[maxn];

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

void prepare() {
  fun[0] = fun[1] = 1;
  for (int i = 2; i < maxn; ++i) {
    fun[i] = fun[i - 1] * i % mod;
  }
  infun[maxn - 1] = qp(fun[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; --i) {
    infun[i] = infun[i + 1] * (i + 1) % mod;
  }
}

ll C(ll n, ll m) {
  if (n < 0 || m < 0 || n < m)
    return 0;
  ll res = fun[n];
  res = res * infun[m] % mod;
  res = res * infun[n - m] % mod;
  return res;
}

int main() {
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll ans = 0;
  ll n = s.length();
  prepare();
  for (int i = n; i <= n + k; ++i) {
    ll tmp = C(i - 1, n - 1);
    tmp = tmp * qp(25, max(0ll, i - n)) % mod;
    tmp = tmp * qp(26, max(0ll, n + k - i)) % mod;
    ans = (ans + tmp) % mod;
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string>
#define ll long long

using namespace std;

const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 5;
ll fun[maxn];
ll infun[maxn];

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

void prepare(ll n) {
  fun[0] = fun[1] = 1;
  infun[0] = infun[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fun[i] = fun[i - 1] * i % mod;
    infun[i] = qp(fun[i], mod - 2);
  }
}

ll C(ll n, ll m) {
  if (n < 0 || m < 0 || n < m)
    return 0;
  ll res = fun[n];
  res = res * infun[m] % mod;
  res = res * infun[n - m] % mod;
  return res;
}

int main() {
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll ans = 0;
  ll n = s.length();
  prepare(n + k);
  for (int i = n; i <= n + k; ++i) {
    ll tmp = C(i - 1, n - 1);
    tmp = tmp * qp(25, max(0ll, i - n)) % mod;
    tmp = tmp * qp(26, max(0ll, n + k - i)) % mod;
    ans = (ans + tmp) % 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++)
#define REP(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(2000005);
vector<ll> ifac(2000005);
// べき乗高速化
ll mpow(ll x, ll n) {
  ll ans = 1;
  while (n != 0) {
    if (n & 1)
      ans = ans * x % M;
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}

// aCbを計算
ll comb(ll a, ll b) {
  if (a == 0 && b == 0)
    return 1;
  if (a < b || a < 0) {
    return 0;
  }
  ll temp = ifac[a - b] * ifac[b] % M;
  return temp * fac[a] % M;
}

int main() {
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll l = s.size();
  fac[0] = 1;
  ifac[0] = 1;
  for (ll i = 0; i <= 2000000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
    ifac[i + 1] =
        ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  ll ans = 0;
  for (ll i = 0; i <= k; ++i) {
    ll count = mpow(26, i);
    count *= comb(l + k - i - 1, l - 1);
    count %= M;
    count *= mpow(25, k - i);
    ans += count % M;
    ans %= M;
  }
  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++)
#define REP(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(1000005);
vector<ll> ifac(1000005);
// べき乗高速化
ll mpow(ll x, ll n) {
  ll ans = 1;
  while (n != 0) {
    if (n & 1)
      ans = ans * x % M;
    x = x * x % M;
    n = n >> 1;
  }
  return ans;
}

// aCbを計算
ll comb(ll a, ll b) {
  if (a == 0 && b == 0)
    return 1;
  if (a < b || a < 0) {
    return 0;
  }
  ll temp = ifac[a - b] * ifac[b] % M;
  return temp * fac[a] % M;
}

int main() {
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll l = s.size();
  fac[0] = 1;
  ifac[0] = 1;
  for (ll i = 0; i <= 1000000; i++) {
    fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
    ifac[i + 1] =
        ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  ll ans = 0;
  for (ll i = 0; i <= k; ++i) {
    ll count = mpow(26, i);
    count *= comb(l + k - i - 1, l - 1);
    count %= M;
    count *= mpow(25, k - i);
    ans += count % M;
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;

#define faster                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr);
#define debug(x) cout << #x << " = " << (x) << endl
#define nl "\\n"
#define sp " "

const int MOD = 1e9 + 7, SZ = 3e6 + 5;
int fact[SZ], N;
string s;

ll powmodk(ll a, ll k, ll m) {
  if (k == 0)
    return 1;
  ll r = powmodk(a, k / 2, m);
  r = (r * r) % m;
  if (k % 2)
    r = (r * a) % m;
  return r;
}

inline ll fix(ll x) { return (x % MOD + MOD) % MOD; }

inline ll modinverse(ll a) { return powmodk(fix(a), MOD - 2, MOD); }

ll nck(int n, int k) {
  ll num = fact[n];
  ll den = modinverse(1LL * fact[n - k] * fact[k]);
  return fix(num * den);
}

int main() {
  faster fact[0] = 1;
  for (int i = 1; i < SZ; i++) {
    fact[i] = fix(1LL * i * fact[i - 1]);
  }

  cin >> N >> s;
  N += int(s.length());
  ll ans = powmodk(26, N, MOD);

  for (int i = 0; i < int(s.size()); i++) {
    ll pow = powmodk(25, N - i, MOD);
    ans -= fix(nck(N, i) * pow);
  }

  cout << fix(ans) << nl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;

#define faster                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);                                                            \\
  cout.tie(nullptr);
#define debug(x) cout << #x << " = " << (x) << endl
#define nl "\\n"
#define sp " "

const int MOD = 1e9 + 7, SZ = 1e6 + 5;
int fact[SZ], N;
string s;

ll powmodk(ll a, ll k, ll m) {
  if (k == 0)
    return 1;
  ll r = powmodk(a, k / 2, m);
  r = (r * r) % m;
  if (k % 2)
    r = (r * a) % m;
  return r;
}

inline ll fix(ll x) { return (x % MOD + MOD) % MOD; }

inline ll modinverse(ll a) { return powmodk(fix(a), MOD - 2, MOD); }

ll nck(int n, int k) {
  ll num = fact[n];
  ll den = modinverse(1LL * fact[n - k] * fact[k]);
  return fix(num * den);
}

int main() {
  faster fact[0] = 1;
  for (int i = 1; i < SZ; i++) {
    fact[i] = fix(1LL * i * fact[i - 1]);
  }

  cin >> N >> s;
  N += int(s.length());
  ll ans = powmodk(26, N, MOD);

  for (int i = 0; i < int(s.size()); i++) {
    ll pow = powmodk(25, N - i, MOD);
    ans -= fix(nck(N, i) * pow);
  }

  cout << fix(ans) << nl;
}
Problem p02632 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod = 1000000007;
const ll inf = 1e18;

ll factmod(ll a, ll b, ll m) {
  if (a < b)
    return 0;
  ll s = 1;
  while (a >= b) {
    s = s * a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

ll combmod(ll a, ll b, ll m) {
  if (b == 0)
    return 1;
  ll c = factmod(a, a - b + 1, m);
  ll d = modinv(factmod(b, 1, m), m);
  ll e = (c * d) % m;
  return e;
}

ll powmod(ll a, ll n, ll m) {
  if (n == 0)
    return 1;

  if (n % 2 == 0) {
    ll r = powmod(a, n / 2, m);
    return r * r % m;
  }

  return a * powmod(a, n - 1, m) % m;
}

int main() {

  ll k;
  string s;
  cin >> k >> s;
  ll n = s.size();

  ll t = 0;
  ll c, d, e;
  ll a = 1;
  c = combmod(n + k - 1, n - 1, mod);
  d = powmod(25, k, mod);
  e = powmod(26, 0, mod);
  a *= c;
  a %= mod;
  a *= d;
  a %= mod;
  a *= e;
  a %= mod;
  t += a;
  t %= mod;

  for (int i = 1; i <= k; i++) {
    a = 1;
    c = (((c * modinv(n + k - i, mod)) % mod) * (k - i + 1)) % mod;
    a *= c;
    d = (d * modinv(25, mod)) % mod;
    a = (a * d) % mod;
    e = e * 26 % mod;
    a = a * e % mod;
    t += a;
    t %= mod;
  }

  cout << t << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod = 1000000007;
const ll inf = 1e18;

ll factmod(ll a, ll b, ll m) {
  if (a < b)
    return 0;
  ll s = 1;
  while (a >= b) {
    s = s * a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

ll combmod(ll a, ll b, ll m) {
  if (b == 0)
    return 1;
  ll c = factmod(a, a - b + 1, m);
  ll d = modinv(factmod(b, 1, m), m);
  ll e = (c * d) % m;
  return e;
}

ll powmod(ll a, ll n, ll m) {
  if (n == 0)
    return 1;

  if (n % 2 == 0) {
    ll r = powmod(a, n / 2, m);
    return r * r % m;
  }

  return a * powmod(a, n - 1, m) % m;
}

int main() {

  ll k;
  string s;
  cin >> k >> s;
  ll n = s.size();

  ll t = 0;
  for (int i = 0; i <= k; i++) {
    ll a = 1;
    a *= combmod(n + k - i - 1, n - 1, mod);
    a %= mod;
    a *= powmod(25, k - i, mod);
    a %= mod;
    a *= powmod(26, i, mod);
    a %= mod;
    t += a;
    t %= mod;
  }

  cout << t << 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 rep2(i, N) for (int i = 1; i <= N; i++)
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;

// status unsolved
long long MOD = mod;
#define SIZE 2000005
long long fac[SIZE], finv[SIZE], inv[SIZE];

void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < SIZE; 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 C(long long n, long long k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
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() {
  long long k;
  cin >> k;
  string s;
  cin >> s;

  make();

  // long long now=C(k+s.size(),s.size());

  /*
      文字列sの最後の文字Snの位置を固定して
      Sn以降は26文字のどれでも使っていよい、
  */
  long long ans = 0;
  long long L = s.size() + k;
  long long l = s.size();
  for (long long i = s.size(); i <= L; i++) {
    long long total = modpow(26, L - i);
    total *= C(i - 1, s.size() - 1);
    total %= mod;

    total *= modpow(25, i - l);
    total %= mod;

    // total*=modpow(26,L-i);
    // total%=mod;

    ans += total;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
/*


*/


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, N) for (int i = 1; i <= N; i++)
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;

// status unsolved
long long MOD = mod;
#define SIZE 200005
long long fac[SIZE], finv[SIZE], inv[SIZE];

void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < SIZE; 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 C(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;
}
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() {
  long long k;
  cin >> k;
  string s;
  cin >> s;

  make();

  // long long now=C(k+s.size(),s.size());

  /*
      文字列sの最後の文字Snの位置を固定して
      Sn以降は26文字のどれでも使っていよい、
  */
  long long ans = 0;
  long long L = s.size() + k;
  long long l = s.size();
  for (long long i = s.size(); i <= L; i++) {
    long long total = modpow(26, L - i);
    total *= C(i - 1, s.size() - 1);
    total %= mod;

    total *= modpow(25, i - l);
    total %= mod;

    // total*=modpow(26,L-i);
    // total%=mod;

    ans += total;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
/*


*/
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1

const int maxn = 3e6 + 10;
const ll mod = 1e9 + 7;
const double pi = acos(-1);

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

ll ji[maxn];
void init() {
  ji[0] = 1;
  for (int i = 1; i < maxn; i++)
    ji[i] = ji[i - 1] * i % mod;
}

ll c(ll a, ll n) {
  return ji[n] * qpow(ji[a], mod - 2) % mod * qpow(ji[n - a], mod - 2) % mod;
}

int main() {
  init();
  ll n;
  string s;
  cin >> n >> s;
  ll k = s.length();
  ll len = k + n;
  ll ans = 0;
  for (int i = 1; i <= len - k + 1; i++) {
    ans = (ans + qpow(26, i - 1) * qpow(25, len - i - k + 1) % mod *
                     c(k - 1, len - i) % mod) %
          mod;
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1

const int maxn = 1e6 + 10;
const ll mod = 1e9 + 7;
const double pi = acos(-1);

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

ll ji[maxn];
void init() {
  ji[0] = 1;
  for (int i = 1; i < maxn; i++)
    ji[i] = ji[i - 1] * i % mod;
}

ll c(ll a, ll n) {
  return ji[n] * qpow(ji[a], mod - 2) % mod * qpow(ji[n - a], mod - 2) % mod;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn], facinv[maxn], bin25[maxn], bin26[maxn];
void pre() {
  fac[0] = 1;
  for (int i = 1; i < maxn; ++i)
    fac[i] = fac[i - 1] * i % mod;
  inv[1] = 1;
  for (int i = 2; i < maxn; ++i)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  facinv[0] = 1;
  for (int i = 1; i < maxn; ++i)
    facinv[i] = facinv[i - 1] * inv[i] % mod;
  bin25[0] = 1;
  for (int i = 1; i < maxn; ++i)
    bin25[i] = bin25[i - 1] * 25 % mod;
  bin26[0] = 1;
  for (int i = 1; i < maxn; ++i)
    bin26[i] = bin26[i - 1] * 26 % mod;
}
ll C(int n, int m) {
  return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;
}
ll ans;
int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.length();
  int m = k + n;
  pre();
  for (int i = 0; i <= k; ++i)
    ans = (ans + bin26[i] * C(m - i - 1, n - 1) % mod * bin25[m - i - n]) % mod;
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn], facinv[maxn], bin25[maxn], bin26[maxn];
void pre() {
  fac[0] = 1;
  for (int i = 1; i < maxn; ++i)
    fac[i] = fac[i - 1] * i % mod;
  inv[1] = 1;
  for (int i = 2; i < maxn; ++i)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  facinv[0] = 1;
  for (int i = 1; i < maxn; ++i)
    facinv[i] = facinv[i - 1] * inv[i] % mod;
  bin25[0] = 1;
  for (int i = 1; i < maxn; ++i)
    bin25[i] = bin25[i - 1] * 25 % mod;
  bin26[0] = 1;
  for (int i = 1; i < maxn; ++i)
    bin26[i] = bin26[i - 1] * 26 % mod;
}
ll C(int n, int m) {
  return n < m ? 0 : fac[n] * facinv[m] % mod * facinv[n - m] % mod;
}
ll ans;
int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.length();
  int m = k + n;
  pre();
  for (int i = 0; i <= k; ++i)
    ans = (ans + bin26[i] * C(m - i - 1, n - 1) % mod * bin25[m - i - n]) % mod;
  cout << ans << endl;
  return 0;
}