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

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

int fact[N], infact[N];

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

void init() {
  fact[0] = 1, infact[0] = 1;
  for (int i = 1; i < N; ++i) {
    fact[i] = (ll)fact[i - 1] * i % mod;
    infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2) % mod;
  }
}

ll C(int a, int b) {
  return (ll)fact[a] * infact[b] % mod * (ll)infact[a - b] % mod;
}

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

  int len = s.length();
  int n = k + len;
  init(); // 预处理阶乘

  ll ans = 0;
  for (int i = len; i <= n; i++) {
    ll t =
        C(i - 1, len - 1) * qmi(25, i - len) % mod * (ll)qmi(26, n - i) % mod;
    ans = (ans % mod + t % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;

int fact[N], infact[N];

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

void init() {
  fact[0] = 1, infact[0] = 1;
  for (int i = 1; i < N; ++i) {
    fact[i] = (ll)fact[i - 1] * i % mod;
    infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2) % mod;
  }
}

ll C(int a, int b) {
  return (ll)fact[a] * infact[b] % mod * (ll)infact[a - b] % mod;
}

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

  int len = s.length();
  int n = k + len;
  init(); // 预处理阶乘

  ll ans = 0;
  for (int i = len; i <= n; i++) {
    ll t =
        C(i - 1, len - 1) * qmi(25, i - len) % mod * (ll)qmi(26, n - i) % mod;
    ans = (ans % mod + t % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>
char s[1000011];
int n, k;
const int p = 1e9 + 7;
inline int qpow(int bs, int ex) {
  int ans = 1;
  while (ex) {
    if (ex & 1)
      ans = 1ll * ans * bs % p;
    bs = 1ll * bs * bs % p;
    ex >>= 1;
  }
  return ans;
}
int fac[2000001], ifac[2000001];
int main() {
  scanf("%d%s", &k, s + 1);
  n = strlen(s + 1);
  int ans = 0;
  fac[0] = 1;
  for (int i = 1; i <= 2e6; ++i)
    fac[i] = 1ll * fac[i - 1] * i % p;
  ifac[2000000] = qpow(fac[2000000], p - 2);
  for (int i = 2e6 - 1; i >= 0; --i)
    ifac[i] = 1ll * ifac[i + 1] * (i + 1) % p;
  for (int i = 0; i <= k; ++i)
    (ans += 1ll * fac[n + k - i - 1] * ifac[n - 1] % p * ifac[k - i] % p *
            qpow(26, i) % p * qpow(25, k - i) % p) %= p;
  printf("%d\\n", ans);
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <cstring>
char s[1000011];
int n, k;
const int p = 1e9 + 7;
inline int qpow(int bs, int ex) {
  int ans = 1;
  while (ex) {
    if (ex & 1)
      ans = 1ll * ans * bs % p;
    bs = 1ll * bs * bs % p;
    ex >>= 1;
  }
  return ans;
}
int fac[1000001], ifac[1000001];
int main() {
  scanf("%d%s", &k, s + 1);
  n = strlen(s + 1);
  int ans = 0;
  fac[0] = 1;
  for (int i = 1; i <= 1e6; ++i)
    fac[i] = 1ll * fac[i - 1] * i % p;
  ifac[1000000] = qpow(fac[1000000], p - 2);
  for (int i = 1e6 - 1; i >= 0; --i)
    ifac[i] = 1ll * ifac[i + 1] * (i + 1) % p;
  for (int i = 0; i <= k; ++i)
    (ans += 1ll * fac[n + k - i - 1] * ifac[n - 1] % p * ifac[k - i] % p *
            qpow(26, i) % p * qpow(25, k - i) % p) %= p;
  printf("%d\\n", ans);
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> Q;

const int inf1 = 1e9 + 9;
const ll inf2 = 8e18 + 9;
const ll mol = 1e9 + 7;
const int maxn = 2e6 + 9;
const ll maxx = 1e5 + 9;

int n, len;
string s;
ll fac[maxn] = {1};

inline ll qpow(ll x, ll t) {
  ll res = 1;
  while (t) {
    if (t & 1)
      res = (res * x) % mol;
    t >>= 1;
    x = (x * x) % mol;
  }
  return res;
}
void init() {
  cin >> n >> s;
  len = s.size();
  for (int i = 1; i < maxn; i++)
    fac[i] = fac[i - 1] * i % mol;
}
inline ll inv(ll t) { return qpow(t, mol - 2); }
inline ll c(ll n, ll r) {
  if (!n || !r)
    return 1;
  return fac[n] * inv(fac[r]) % mol * inv(fac[n - r]) % mol;
}
int main() {
  init();
  ll ans = 0;
  for (int i = len; i <= len + n; i++) {
    ll tmp = c(i - 1, len - 1);
    tmp = (tmp * qpow(25, i - len)) % mol;
    tmp = (tmp * qpow(26, len + n - i)) % mol;
    ans = (ans + tmp) % mol;
  }
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> Q;

const int inf1 = 1e9 + 9;
const ll inf2 = 8e18 + 9;
const ll mol = 1e9 + 7;
const int maxn = 1e6 + 9;
const ll maxx = 1e5 + 9;

int n, len;
string s;
ll fac[maxn] = {1};

inline ll qpow(ll x, ll t) {
  ll res = 1;
  while (t) {
    if (t & 1)
      res = (res * x) % mol;
    t >>= 1;
    x = (x * x) % mol;
  }
  return res;
}
void init() {
  cin >> n >> s;
  len = s.size();
  for (int i = 1; i < maxn; i++)
    fac[i] = fac[i - 1] * i % mol;
}
inline ll inv(ll t) { return qpow(t, mol - 2); }
inline ll c(ll n, ll r) {
  if (!n || !r)
    return 1;
  return fac[n] * inv(fac[r]) % mol * inv(fac[n - r]) % mol;
}
int main() {
  init();
  ll ans = 0;
  for (int i = len; i <= len + n; i++) {
    ll tmp = c(i - 1, len - 1);
    tmp = (tmp * qpow(25, i - len)) % mol;
    tmp = (tmp * qpow(26, len + n - i)) % mol;
    ans = (ans + tmp) % mol;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
const ll M = 1e9 + 7;

ll n, m, ans = 0, fac[2000010];
string s;

ll mpow(ll a, ll n) {
  int ret = 1;
  for (ll i = n; i; i >>= 1, a = a * a % M)
    if (i & 1)
      ret = ret * a % M;
  return ret;
}

int main() {
  cin >> n >> s;
  m = s.size();
  fac[0] = 1;
  for (int i = 1; i < m + n; i++)
    fac[i] = (fac[i - 1] * i) % M;
  for (int i = 0; i <= n; i++) {
    ll c =
        (fac[m + n - i - 1] * mpow((fac[m - 1] * fac[n - i]) % M, M - 2)) % M;
    ans = (ans + (mpow(26, i) * c) % M * mpow(25, n - i)) % M;
  }
  cout << ans;
}


Error: WA

Fixed submission:

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

typedef long long ll;
const ll M = 1e9 + 7;

ll n, m, ans = 0, fac[1000010];
string s;

ll mpow(ll a, ll n) {
  int ret = 1;
  for (ll i = n; i; i >>= 1, a = a * a % M)
    if (i & 1)
      ret = ret * a % M;
  return ret;
}

int main() {
  cin >> n >> s;
  m = s.size();
  fac[0] = 1;
  for (int i = 1; i < m + n; i++)
    fac[i] = (fac[i - 1] * i) % M;
  for (int i = 0; i <= n; i++) {
    ll c =
        (fac[m + n - i - 1] * mpow((fac[m - 1] * fac[n - i]) % M, M - 2)) % M;
    ans = (ans + (mpow(26, i) * c) % M * mpow(25, n - i)) % M;
  }
  cout << ans;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> Pii;
typedef pair<ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e6) + 7;
const int maxm = 300;

char s[maxn];
ll n, k, a[maxn], b[maxn];
ll C(ll n, ll m) {
  if (m > n)
    return 0;
  return a[n] * b[m] % mod * b[n - m] % mod;
}
ll power(ll a, ll b) {
  ll ans = 1;
  for (; b; a = a * a % mod, b >>= 1)
    if (b & 1)
      ans = ans * a % mod;
  return ans;
}

int main() {

  // freopen("in.in", "r", stdin);
  scanf("%lld%s", &k, s + 1);
  n = strlen(s + 1);
  a[0] = a[1] = b[0] = b[1] = 1;
  for (ll i = 2; i <= n + k; i++) {
    b[i] = (mod - mod / i) * b[mod % i] % mod;
  }
  for (ll i = 2; i <= n + k; i++) {
    a[i] = a[i - 1] * i % mod;
    b[i] = b[i - 1] * b[i] % mod;
  }
  ll res = 0;
  for (ll i = 0; i <= k;
       i++) { // 先选出i个字符放在最左边, 和原串第一个字符在一起
    res = (res + C(n + k - i - 1, k - i) * power(26, i) % mod *
                     power(25, k - i) % mod) %
          mod;
  }
  printf("%lld", res);

  return 0;
}
//           f             o
// 26 * 26 * 1 * 25 * 25 * 1 * 25 * 25
// [a, z]    [a, f)∪(f, z)  [a, o)∪(o, z]
// |<----------- n + k ------------->|


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> Pii;
typedef pair<ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

char s[maxn];
ll n, k, a[maxn], b[maxn];
ll C(ll n, ll m) {
  if (m > n)
    return 0;
  return a[n] * b[m] % mod * b[n - m] % mod;
}
ll power(ll a, ll b) {
  ll ans = 1;
  for (; b; a = a * a % mod, b >>= 1)
    if (b & 1)
      ans = ans * a % mod;
  return ans;
}

int main() {

  // freopen("in.in", "r", stdin);
  scanf("%lld%s", &k, s + 1);
  n = strlen(s + 1);
  a[0] = a[1] = b[0] = b[1] = 1;
  for (ll i = 2; i <= n + k; i++) {
    b[i] = (mod - mod / i) * b[mod % i] % mod;
  }
  for (ll i = 2; i <= n + k; i++) {
    a[i] = a[i - 1] * i % mod;
    b[i] = b[i - 1] * b[i] % mod;
  }
  ll res = 0;
  for (ll i = 0; i <= k;
       i++) { // 先选出i个字符放在最左边, 和原串第一个字符在一起
    res = (res + C(n + k - i - 1, k - i) * power(26, i) % mod *
                     power(25, k - i) % mod) %
          mod;
  }
  printf("%lld", res);

  return 0;
}
//           f             o
// 26 * 26 * 1 * 25 * 25 * 1 * 25 * 25
// [a, z]    [a, f)∪(f, z)  [a, o)∪(o, z]
// |<----------- n + k ------------->|
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define IO                                                                     \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\\n"
using namespace std;
using ll = long long;

ll mod = 1000000007;

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

ll fact[2000005], invfact[2000005];

ll ncr(ll n, ll r) {
  ll ret = fact[n];
  ret = (ret * invfact[r]) % mod;
  ret = (ret * invfact[n - r]) % mod;
  return ret;
}

signed main() {
  IO;
  fact[0] = 1;
  invfact[0] = expo(fact[0], mod - 2);
  for (ll i = 1; i <= 2000000; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
    invfact[i] = expo(fact[i], mod - 2);
  }
  ll k, sz;
  string s;
  cin >> k >> s;
  sz = s.size();
  ll pr = 0;
  for (ll i = sz; i <= sz + k; ++i) {
    ll ans = 1;
    ans = (ans * expo(26, sz + k - i)) % mod;
    ans = (ans * expo(25, i - sz)) % mod;
    ll r1 = ncr(sz - 1 + i - sz, sz - 1);
    ans = (ans * r1) % mod;
    pr = (pr + ans) % mod;
  }
  cout << pr;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define IO                                                                     \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\\n"
using namespace std;
using ll = long long;

ll mod = 1000000007;

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

ll fact[1000005], invfact[1000005];

ll ncr(ll n, ll r) {
  ll ret = fact[n];
  ret = (ret * invfact[r]) % mod;
  ret = (ret * invfact[n - r]) % mod;
  return ret;
}

signed main() {
  IO;
  fact[0] = 1;
  invfact[0] = expo(fact[0], mod - 2);
  for (ll i = 1; i <= 1000000; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
    invfact[i] = expo(fact[i], mod - 2);
  }
  ll k, sz;
  string s;
  cin >> k >> s;
  sz = s.size();
  ll pr = 0;
  for (ll i = sz; i <= sz + k; ++i) {
    ll ans = 1;
    ans = (ans * expo(26, sz + k - i)) % mod;
    ans = (ans * expo(25, i - sz)) % mod;
    ll r1 = ncr(sz - 1 + i - sz, sz - 1);
    ans = (ans * r1) % mod;
    pr = (pr + ans) % mod;
  }
  cout << pr;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm> //sort,reverse
#include <deque>     //double_ended queue
#include <iostream>
#include <map>   //map
#include <queue> //queue,priority_queue
#include <string>
#include <utility> //pair
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P; // Pでpair<-,->を表す。
const LL MAX = 2000010;
const LL MOD = 1000000007;
typedef map<LL, LL>::iterator Itr;

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

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

/*ここまで*/

int main() {
  // 前処理
  COMinit();
  LL k;
  cin >> k;
  string s;
  cin >> s;
  LL n = s.size();
  LL ans[n + k + 1];
  LL b[n + k + 1];
  LL pow[n + k + 1];
  for (int i = 0; i <= n + k; i++) {
    if (i == 0) {
      pow[i] = 1;
    } else {
      pow[i] = (pow[i - 1] * 25) % MOD;
    }
  }
  for (int i = 0; i <= n + k; i++) {
    ans[i] = 0;
    b[i] = 0;
  }
  for (int i = 0; i <= n + k; i++) {
    if (i < n - 1) {
      b[i] = 0;
    } else {
      b[i] = (pow[i - n + 1] * COM(i, n - 1)) % MOD;
    }
  }
  for (int i = 1; i <= n + k; i++) {
    ans[i] = (26 * ans[i - 1] + b[i - 1]) % MOD;
  }
  cout << ans[n + k] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm> //sort,reverse
#include <deque>     //double_ended queue
#include <iostream>
#include <map>   //map
#include <queue> //queue,priority_queue
#include <string>
#include <utility> //pair
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P; // Pでpair<-,->を表す。
const LL MAX = 2000010;
const LL MOD = 1000000007;
typedef map<LL, LL>::iterator Itr;

int main() {
  LL k;
  cin >> k;
  string s;
  cin >> s;
  LL n = s.size();
  LL ans[n + 1];
  for (int i = 0; i <= n; i++) {
    ans[i] = 0;
  }
  ans[0] = 1;
  for (int j = 0; j < n + k; j++) {
    for (int i = n; i >= 0; i--) {
      if (i == 0) {
        ans[i] = (25 * ans[i]) % MOD;
      } else if (i == n) {
        ans[i] = (26 * ans[i] + ans[i - 1]) % MOD;
      } else {
        ans[i] = (25 * ans[i] + ans[i - 1]) % MOD;
      }
    }
  }
  cout << ans[n] << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int K, n;
string s;
ll mypow(int x, int t) {
  ll ans = 1, res = x;
  while (t) {
    if (t & 1)
      ans = ans * res % MOD;
    res = res * res % MOD, t >>= 1;
  }
  return ans;
}
ll a[4000004], inv[4000004];
void init() {
  a[0] = 1, inv[1] = 1;
  for (int i = 1; i <= 4e6; i++)
    a[i] = a[i - 1] * i % MOD;
  for (int i = 2; i <= 4e6; i++)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  inv[0] = 1;
  for (int i = 1; i <= 4e6; i++)
    inv[i] = inv[i - 1] * inv[i] % MOD;
}
ll C(int A, int B) { return a[A + B] * inv[A] % MOD * inv[B] % MOD; }
int main() {
  init();
  cin >> K >> s, n = s.size();
  ll ans = 0;
  for (int i = 0; i <= K; i++) {
    ans += C(n - 1, i) * mypow(25, i) % MOD * mypow(26, K - i) % MOD;
    ans %= MOD;
  }
  cout << ans;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int K, n;
string s;
ll mypow(int x, int t) {
  ll ans = 1, res = x;
  while (t) {
    if (t & 1)
      ans = ans * res % MOD;
    res = res * res % MOD, t >>= 1;
  }
  return ans;
}
ll a[400004], inv[400004];
void init() {
  a[0] = 1, inv[1] = 1;
  for (int i = 1; i <= 4e5; i++)
    a[i] = a[i - 1] * i % MOD;
  for (int i = 2; i <= 4e5; i++)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  inv[0] = 1;
  for (int i = 1; i <= 4e5; i++)
    inv[i] = inv[i - 1] * inv[i] % MOD;
}
ll C(int A, int B) { return a[A + B] * inv[A] % MOD * inv[B] % MOD; }
int main() {
  init();
  cin >> K >> s, n = s.size();
  ll ans = 0;
  for (int i = 0; i <= K; i++) {
    ans += C(n - 1, i) * mypow(25, i) % MOD * mypow(26, K - i) % MOD;
    ans %= MOD;
  }
  cout << ans;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
const ll MOD = 1000000007;
const ll MAX = 2100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  repl(i, 2, MAX) {
    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 or k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  COMinit();

  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  ll ans = 0;
  rep(i, k + 1) {
    ll p = COM(n + k - i - 1, n - 1) * modpow(25, k - i) % MOD * modpow(26, i) %
           MOD;
    ans = (ans + p) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
const ll MOD = 1000000007;
const ll MAX = 1100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  repl(i, 2, MAX) {
    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 or k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  COMinit();

  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  ll ans = 0;
  rep(i, k + 1) {
    ll p = COM(n + k - i - 1, n - 1) * modpow(25, k - i) % MOD * modpow(26, i) %
           MOD;
    ans = (ans + p) % MOD;
  }
  cout << ans << endl;
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

const int MAX = 2000005;
const ll 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 pow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  ll ans = 0;
  COMinit();
  rep(i, k + 1) {
    ll tmp = pow(25ll, (ll)i) * COM(i + n - 1, n - 1) % MOD;
    tmp *= pow(26ll, (ll)(k - i));
    tmp %= MOD;
    ans += tmp;
    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)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX = 1000005;
const ll 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 pow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  ll ans = 0;
  COMinit();
  rep(i, k + 1) {
    ll tmp = pow(25ll, (ll)i) * COM(i + n - 1, n - 1) % MOD;
    tmp *= pow(26ll, (ll)(k - i));
    tmp %= MOD;
    ans += tmp;
    ans %= 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 MOD = 1000000007;

ll pd[2000010];
ll rd[2000010];
ll Ep(int x, int y) {
  if (y == 0)
    return 1;
  if (y == 1)
    return x;
  ll r = Ep(x, y / 2);
  if (y % 2 == 1)
    return r * r % MOD * x % MOD;
  else
    return r * r % MOD;
}
ll Ftl(ll x) {
  if (x == 1 || x == 0)
    return 1;
  if (pd[x] != 0)
    return pd[x];
  return pd[x] = Ftl(x - 1) * x % MOD;
}
ll rFtl(ll x) {
  if (x == 1 || x == 0)
    return 1;
  if (rd[x] != 0)
    return rd[x];
  return rd[x] = rFtl(x - 1) * Ep(x, MOD - 2) % MOD;
}
ll comb(ll m, ll n) {
  if (m < n)
    return 0;
  return Ftl(m) * rFtl(n) % MOD * rFtl(m - n) % MOD;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int k2 = s.size();
  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans += Ep(26, k - i) * Ep(25, i) % MOD * comb(k2 + i - 1, i) % MOD;
    ans %= MOD;
    // cout << ans << endl;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

ll pd[1000010];
ll rd[1000010];
ll Ep(int x, int y) {
  if (y == 0)
    return 1;
  if (y == 1)
    return x;
  ll r = Ep(x, y / 2);
  if (y % 2 == 1)
    return r * r % MOD * x % MOD;
  else
    return r * r % MOD;
}
ll Ftl(ll x) {
  if (x == 1 || x == 0)
    return 1;
  if (pd[x] != 0)
    return pd[x];
  return pd[x] = Ftl(x - 1) * x % MOD;
}
ll rFtl(ll x) {
  if (x == 1 || x == 0)
    return 1;
  if (rd[x] != 0)
    return rd[x];
  return rd[x] = rFtl(x - 1) * Ep(x, MOD - 2) % MOD;
}
ll comb(ll m, ll n) {
  if (m < n)
    return 0;
  return Ftl(m) * rFtl(n) % MOD * rFtl(m - n) % MOD;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  int k2 = s.size();
  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ans += Ep(26, k - i) * Ep(25, i) % MOD * comb(k2 + i - 1, i) % MOD;
    ans %= MOD;
    // cout << ans << endl;
  }
  cout << ans << endl;
}