alexjercan/bugnet huggingface dataset:
Problem p02632 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define lli long long
lli M = 1e9 + 7;

#define MAXN 10000001
lli power(lli x, lli y) {
  lli res = 1; // Initialize result

  x = x % M; // Update x if it is more than or
             // equal to p

  if (x == 0)
    return 0; // In case x is divisible by p;

  while (y > 0) {
    // If y is odd, multiply x with result
    if (y & 1)
      res = (res * x) % M;

    // y must be even now
    y = y >> 1; // y = y/2
    x = (x * x) % M;
  }
  return res;
}
lli modInverse(int a, int m) { return power(a, m - 2); }

int main() {
  lli q = 1;
  // cin>>q;
  time_t start, end;
  time(&start);
  for (lli tc = 1; tc <= q; tc++) {
    lli n;
    string s;
    cin >> n;
    cin >> s;
    lli ans = 1;
    lli d = power(26, n);
    lli f[n + 1];
    f[0] = 1;
    lli k = s.length();
    for (int i = 1; i <= n; i++) {
      f[i] = ((f[i - 1] * (i + k - 1)) % M * modInverse(i, M)) % M;
    }
    ans = d;
    lli x = modInverse(26, M);
    for (int i = 0; i < n; i++) {
      d = ((d * 25) % M * x) % M;
      ans = (ans + (f[i + 1] * d) % M) % M;
    }
    cout << ans << endl;
  }

  time(&end);
  // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define lli long long
lli M = 1e9 + 7;

#define MAXN 10000001
lli power(lli x, lli y) {
  if (y == 0)
    return 1;
  lli p = power(x, y / 2) % M;
  p = (p * p) % M;

  return (y % 2 == 0) ? p : (x * p) % M;
}
lli modInverse(int a, int m) { return power(a, m - 2); }

int main() {
  lli q = 1;
  // cin>>q;
  time_t start, end;
  time(&start);
  for (lli tc = 1; tc <= q; tc++) {
    lli n;
    string s;
    cin >> n;
    cin >> s;
    lli ans = 1;
    lli d = power(26, n);
    lli f[n + 1];
    f[0] = 1;
    lli k = s.length();
    for (int i = 1; i <= n; i++) {
      f[i] = ((f[i - 1] * (i + k - 1)) % M * modInverse(i, M)) % M;
    }
    ans = d;
    for (int i = 0; i < n; i++) {
      d = ((d * 25) % M * modInverse(26, M)) % M;
      ans = (ans + (f[i + 1] * d) % M) % M;
    }
    cout << ans << endl;
  }

  time(&end);
  // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ar array

const ll mod = 1e9 + 7;

ll pwr(ll a, ll b) {
  ll ret = 1;
  while (b > 0) {
    if (b % 2 == 1)
      ret = ret * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ret;
}

const int N = 2e6 + 5;
ll f[N], inv[N];

ll C(int n, int k) {
  if (k > n || k < 0)
    return 0;
  return f[n] * (inv[k] * inv[n - k] % mod) % mod;
}

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

  int k, n;
  string s;
  cin >> k >> s;
  n = (int)s.size() + k;

  f[0] = 1;
  inv[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = (ll)f[i - 1] * i % mod;
    inv[i] = pwr(f[i], mod - 2);
  }

  ll ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    ans = (ans + pwr(25, n - i) * C(n, i) % mod) % mod;
  }
  ans = (pwr(26, n) - ans + mod) % mod;

  cout << ans << '\\n';
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ar array

const ll mod = 1e9 + 7;

ll pwr(ll a, ll b) {
  ll ret = 1;
  while (b > 0) {
    if (b % 2 == 1)
      ret = ret * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ret;
}

const int N = 1e6 + 5;
ll f[N], inv[N];

ll C(int n, int k) {
  if (k > n || k < 0)
    return 0;
  return f[n] * (inv[k] * inv[n - k] % mod) % mod;
}

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

  int k, n;
  string s;
  cin >> k >> s;
  n = (int)s.size() + k;

  f[0] = 1;
  inv[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = (ll)f[i - 1] * i % mod;
    inv[i] = pwr(f[i], mod - 2);
  }

  ll ans = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    ans = (ans + pwr(25, n - i) * C(n, i) % mod) % mod;
  }
  ans = (pwr(26, n) - ans + mod) % mod;

  cout << ans << '\\n';
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
const int M = 1e9 + 7;

ll mul(ll a, ll b) { return (a * b) % M; }
ll mod_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1)
      r = mul(r, a);
    b >>= 1;
    a = mul(a, a);
  }
  return r;
}
struct combination {
  vector<int> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < M);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = mul(fact[i - 1], i);
    ifact[n] = mod_pow(fact[n], M - 2);
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = mul(ifact[i], i);
  }
  int operator()(int n, int k) {
    assert(k >= 0 && k <= n);
    return mul(fact[n], mul(ifact[k], ifact[n - k]));
  }
} C(2000005);

void solve() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = mod_pow(25, i);
    now = (now * mod_pow(26, k - i)) % M;
    now = (now * C(n - 1 + i, n - 1)) % M;
    ans = (ans + now) % M;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
const int M = 1e9 + 7;

ll mul(ll a, ll b) { return (a * b) % M; }
ll mod_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1)
      r = mul(r, a);
    b >>= 1;
    a = mul(a, a);
  }
  return r;
}
struct combination {
  vector<int> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < M);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = mul(fact[i - 1], i);
    ifact[n] = mod_pow(fact[n], M - 2);
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = mul(ifact[i], i);
  }
  int operator()(int n, int k) {
    assert(k >= 0 && k <= n);
    return mul(fact[n], mul(ifact[k], ifact[n - k]));
  }
} C(200005);

void solve() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = mod_pow(25, i);
    now = (now * mod_pow(26, k - i)) % M;
    now = (now * C(n - 1 + i, n - 1)) % M;
    ans = (ans + now) % M;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  solve();
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int MAX = 2000005;

ll f[MAX];
void init() {
  f[0] = 1;
  for (int i = 1; i < MAX; i++)
    f[i] = (f[i - 1] * i) % MOD;
}

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

ll C(int n, int k) {
  ll a = f[n];
  ll b = f[n - k];
  ll c = f[k];
  ll bc = (b * c) % MOD;
  return (a * inv(bc)) % MOD;
}

ll powmod(ll a, ll n, ll m = MOD) {
  ll ret = 1;
  for (; n > 0; n >>= 1, a = a * a % m) {
    if (n % 2 == 1) {
      ret = ret * a % m;
    }
  }
  return ret;
}

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

  int n = s.size() + k, m = s.size();

  ll ans = 0;
  for (int i = m; i <= n; i++) {
    ll d = C(i - 1, m - 1) * powmod(25, i - m);
    d %= MOD;
    d *= powmod(26, n - i);
    d %= MOD;
    ans += d;
    ans %= MOD;
    // cout << i << " " << d << " " << ans << endl;
  }

  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int MAX = 100005;

ll f[MAX];
void init() {
  f[0] = 1;
  for (int i = 1; i < MAX; i++)
    f[i] = (f[i - 1] * i) % MOD;
}

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

ll C(int n, int k) {
  ll a = f[n];
  ll b = f[n - k];
  ll c = f[k];
  ll bc = (b * c) % MOD;
  return (a * inv(bc)) % MOD;
}

ll powmod(ll a, ll n, ll m = MOD) {
  ll ret = 1;
  for (; n > 0; n >>= 1, a = a * a % m) {
    if (n % 2 == 1) {
      ret = ret * a % m;
    }
  }
  return ret;
}

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

  int n = s.size() + k, m = s.size();

  ll ans = 0;
  for (int i = m; i <= n; i++) {
    ll d = C(i - 1, m - 1) * powmod(25, i - m);
    d %= MOD;
    d *= powmod(26, n - i);
    d %= MOD;
    ans += d;
    ans %= MOD;
    // cout << i << " " << d << " " << ans << endl;
  }

  cout << ans << endl;

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

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

const int MAX = 10000000;
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;
}

long long modpow(int x, int r) {
  if (r == 0) {
    return 1;
  } else if (r % 2 == 0) {
    long long tmp = modpow(x, r / 2);
    return tmp % mod * tmp % mod;
  } else {
    return x % mod * modpow(x, r - 1) % mod;
  }
}

int main() {
  COMinit();
  long long K;
  string S;
  cin >> K >> S;
  long long L = S.length() + K;
  long long N = S.length();
  long long ans = 0;
  for (long long i = N; i <= L; i++) {
    // S_N以降の文字数
    long long p = L - i;
    ans += COM(L - p - 1, N - 1) % mod * modpow(25, K - p) % mod *
           modpow(26, p) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

const int MAX = 1001000;
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;
}

long long modpow(int x, int r) {
  if (r == 0) {
    return 1;
  } else if (r % 2 == 0) {
    long long tmp = modpow(x, r / 2);
    return tmp % mod * tmp % mod;
  } else {
    return x % mod * modpow(x, r - 1) % mod;
  }
}

int main() {
  COMinit();
  long long K;
  string S;
  cin >> K >> S;
  long long L = S.length() + K;
  long long N = S.length();
  long long ans = 0;
  for (long long i = N; i <= L; i++) {
    // S_N以降の文字数
    long long p = L - i;
    ans += COM(L - p - 1, N - 1) % mod * modpow(25, K - p) % mod *
           modpow(26, p) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define FASTIO                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 3e6 + 5;
const int oo = 1e9 + 5;
const int MOD = 1e9 + 7;

LL powermod(LL a, LL b) {
  if (b == 0)
    return 1;
  LL res = powermod(a, b / 2);
  res = (res * res) % MOD;
  if (b & 1)
    res = (res * a) % MOD;
  return res;
}
int fac[N], invfac[N];
void pre() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = (fac[i - 1] * 1LL * i) % MOD;
  invfac[N - 1] = powermod(fac[N - 1], MOD - 2);
  for (int i = N - 2; i >= 0; --i) {
    invfac[i] = (invfac[i + 1] * 1LL * (i + 1)) % MOD;
  }
}
LL ncr(int n, int r) {
  if (r < 0 || r > n)
    return 0;
  LL ans = (fac[n] * 1LL * invfac[r]) % MOD;
  ans = (ans * 1LL * invfac[n - r]) % MOD;
  return ans;
}
void solve() {
  int k;
  cin >> k;
  string str;
  cin >> str;
  int s = str.size();
  LL ans = 0, sixinv = powermod(26, MOD - 2), have = 1, have2 = powermod(26, k);
  for (int i = 0; i <= k; ++i) {
    ans += ((ncr(s + i - 1, s - 1) * have) % MOD * have2) % MOD;
    have2 = (have2 * sixinv) % MOD;
    have = (have * 25) % MOD;
    if (ans >= MOD)
      ans -= MOD;
  }
  cout << ans << '\\n';
}

int main() {
  FASTIO;
  pre();
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define FASTIO                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e6 + 5;
const int oo = 1e9 + 5;
const int MOD = 1e9 + 7;

LL powermod(LL a, LL b) {
  if (b == 0)
    return 1;
  LL res = powermod(a, b / 2);
  res = (res * res) % MOD;
  if (b & 1)
    res = (res * a) % MOD;
  return res;
}
int fac[N], invfac[N];
void pre() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = (fac[i - 1] * 1LL * i) % MOD;
  invfac[N - 1] = powermod(fac[N - 1], MOD - 2);
  for (int i = N - 2; i >= 0; --i) {
    invfac[i] = (invfac[i + 1] * 1LL * (i + 1)) % MOD;
  }
}
LL ncr(int n, int r) {
  if (r < 0 || r > n)
    return 0;
  LL ans = (fac[n] * 1LL * invfac[r]) % MOD;
  ans = (ans * 1LL * invfac[n - r]) % MOD;
  return ans;
}
void solve() {
  int k;
  cin >> k;
  string str;
  cin >> str;
  int s = str.size();
  LL ans = 0, sixinv = powermod(26, MOD - 2), have = 1, have2 = powermod(26, k);
  for (int i = 0; i <= k; ++i) {
    ans += ((ncr(s + i - 1, s - 1) * have) % MOD * have2) % MOD;
    have2 = (have2 * sixinv) % MOD;
    have = (have * 25) % MOD;
    if (ans >= MOD)
      ans -= MOD;
  }
  cout << ans << '\\n';
}

int main() {
  FASTIO;
  pre();
  int t = 1;
  // cin >> t;
  while (t--)
    solve();
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\\n'
#define all(x) (x).begin(), (x).end()
const int INF = 1e9 + 5;
const int N = 2e6 + 10;
const ll mod = 1e9 + 7;

ll fac[N];

ll mul(ll a, ll b) { return a * b % mod; }

ll poww(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1)
      r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll inv(ll x) { return poww(x, mod - 2); }

void add_self(ll &a, ll b) {
  a += b;
  a %= mod;
}

void init() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < N; ++i) {
    fac[i] = mul(fac[i - 1], 1ll * i);
  }
}

ll bino(ll n, ll k) {
  if (k < 0)
    return 1;
  if (!k)
    return 1;
  return mul(fac[n], mul(inv(fac[n - k]), inv(fac[k])));
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  init();
  ll k;
  string s;
  cin >> k >> s;
  ll n = (ll)s.size();
  ll ans = 0;
  for (ll last = 0; last <= k; ++last) {
    ll ch26 = poww(26, last);
    ll ch25 = poww(25, k - last);
    ll chpos = bino(k + n - last - 1, n - 1);
    ll cur = mul(ch26, mul(ch25, chpos));
    add_self(ans, cur);
  }
  cout << ans;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\\n'
#define all(x) (x).begin(), (x).end()
const int INF = 1e9 + 5;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;

ll fac[N];

ll mul(ll a, ll b) { return a * b % mod; }

ll poww(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1)
      r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

ll inv(ll x) { return poww(x, mod - 2); }

void add_self(ll &a, ll b) {
  a += b;
  a %= mod;
}

void init() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < N; ++i) {
    fac[i] = mul(fac[i - 1], 1ll * i);
  }
}

ll bino(ll n, ll k) {
  if (k < 0)
    return 1;
  if (!k)
    return 1;
  return mul(fac[n], mul(inv(fac[n - k]), inv(fac[k])));
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  init();
  ll k;
  string s;
  cin >> k >> s;
  ll n = (ll)s.size();
  ll ans = 0;
  for (ll last = 0; last <= k; ++last) {
    ll ch26 = poww(26, last);
    ll ch25 = poww(25, k - last);
    ll chpos = bino(k + n - last - 1, n - 1);
    ll cur = mul(ch26, mul(ch25, chpos));
    add_self(ans, cur);
  }
  cout << ans;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b, ll mod = 1e9 + 7) {
  a %= mod;
  ll res = 1;
  while (b > 0) {
    if (b % 2 == 1)
      res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

vector<ll> f;
void cominit(ll n = 210000, ll mod = 1e9 + 7) {
  f.resize(n + 1);
  f[0] = 1;
  REP(i, n) f[i + 1] = f[i] * (i + 1) % mod;
}

ll nCr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return f[n] * powmod(f[r] * f[n - r], mod - 2, mod) % mod;
}

ll nPr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return f[n] * powmod(f[n - r], mod - 2, mod) % mod;
}

ll nHr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return nCr(n + r - 1, r, mod);
}

ll k, ans;
string s;
int main() {
  cominit(2100000);
  cin >> k >> s;
  ll sz = s.size();
  ll n = k + sz;
  ans = powmod(26, n);
  REP(i, sz) {
    ans -= nCr(n, i) * powmod(25, n - i) % MOD;
    ans = (ans + MOD * 2) % MOD;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b, ll mod = 1e9 + 7) {
  a %= mod;
  ll res = 1;
  while (b > 0) {
    if (b % 2 == 1)
      res = res * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return res;
}

vector<ll> f;
void cominit(ll n = 1100000, ll mod = 1e9 + 7) {
  f.resize(n + 1);
  f[0] = 1;
  REP(i, n) f[i + 1] = f[i] * (i + 1) % mod;
}

ll nCr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return f[n] * powmod(f[r] * f[n - r], mod - 2, mod) % mod;
}

ll nPr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return f[n] * powmod(f[n - r], mod - 2, mod) % mod;
}

ll nHr(ll n, ll r, ll mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (n < 0 or r < 0)
    return 0;
  return nCr(n + r - 1, r, mod);
}

ll k, ans;
string s;
int main() {
  cominit();
  cin >> k >> s;
  ll sz = s.size();
  ll n = k + sz;
  ans = powmod(26, n);
  REP(i, sz) {
    ans -= nCr(n, i) * powmod(25, n - i) % MOD;
    ans = (ans + MOD * 2) % MOD;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define PER(i, a, b) for (ll i = (a); i >= (b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
const ll INF = 1e18 + 18;
const ll MAX = 2000100;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

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

ll myPow(ll x, ll n, ll m) {
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
// テーブルを作る前処理
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() {
  COMinit();
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll Sz = S.size();
  ll Ans = 0;
  for (ll i = Sz; i <= Sz + K; i++) {
    ll T = COM(i - 1, Sz - 1);
    T *= myPow(25, i - Sz, MOD);
    T %= MOD;
    T *= myPow(26, Sz + K - i, MOD);
    T %= MOD;
    Ans += T;
    Ans %= MOD;
  }
  cout << Ans << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define PER(i, a, b) for (ll i = (a); i >= (b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a) (a).begin(), (a).end()
const ll INF = 1e18 + 18;
const ll MAX = 200100;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

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

ll myPow(ll x, ll n, ll m) {
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
// テーブルを作る前処理
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() {
  COMinit();
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll Sz = S.size();
  ll Ans = 0;
  for (ll i = Sz; i <= Sz + K; i++) {
    ll T = COM(i - 1, Sz - 1);
    // T*=myPow(25, i-Sz, MOD);
    T %= MOD;
    // T*=myPow(26, Sz+K-i, MOD);
    T %= MOD;
    Ans += T;
    Ans %= MOD;
  }
  cout << Ans << endl;
}