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

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
const ll nax = 3e6;
ll fact[nax + 1];
ll mod = 1e9 + 7;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1) {
      ans = (ans * x) % mod;
    }
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}
ll modinverse(ll x) { return power(x, mod - 2); }
ll combi(ll n, ll r) {
  return (fact[n] * modinverse((fact[r] * fact[n - r]) % mod)) % mod;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k, i;
  string s;
  cin >> k >> s;
  fact[0] = 1;
  for (i = 1; i < nax + 1; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  ll tot = power(26, k + s.length());
  for (i = 0; i < s.length(); i++) {
    tot = ((tot - combi(k + s.length(), i) * power(25, k + s.length() - i)) %
               mod +
           mod) %
          mod;
  }
  cout << tot << "\\n";
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
const ll nax = 1e6;
ll fact[nax + 1];
ll mod = 1e9 + 7;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1) {
      ans = (ans * x) % mod;
    }
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}
ll modinverse(ll x) { return power(x, mod - 2); }
ll combi(ll n, ll r) {
  return (fact[n] * modinverse((fact[r] * fact[n - r]) % mod)) % mod;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll k, i;
  string s;
  cin >> k >> s;
  fact[0] = 1;
  for (i = 1; i < nax + 1; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  ll tot = power(26, k + s.length());
  for (i = 0; i < s.length(); i++) {
    tot = ((tot - combi(k + s.length(), i) * power(25, k + s.length() - i)) %
               mod +
           mod) %
          mod;
  }
  cout << tot << "\\n";
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll fact[2000010], inv[2000010], mod = 1e9 + 7;

ll fexpo(ll x, ll y) {
  ll ret = 1;
  while (y) {
    if (y & 1)
      ret = (ret * x) % mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ret;
}

void fac() {
  fact[0] = 1;
  for (ll i = 1; i < 2000010; i++)
    fact[i] = i * fact[i - 1] % mod;
  inv[2000009] = fexpo(fact[2000009], mod - 2);
  for (ll i = 2000008; i >= 0; i--)
    inv[i] = (i + 1) * inv[i + 1] % mod;
}

ll ncr(ll x, ll y) {
  if (y > x)
    return 0;
  ll cnt = fact[x] * inv[x - y] % mod * inv[y] % mod;
  return cnt;
}

void solve() {
  ll k, n;
  string s;
  cin >> k >> s;
  n = s.length();
  ll cnt = 0;
  for (ll i = 0; i <= k; i++) {
    cnt +=
        fexpo(26, i) * fexpo(25, k - i) % mod * ncr(k - i + n - 1, n - 1) % mod;
  }
  cout << cnt % mod << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac();
  // int t;cin>>t;while(t--)
  solve();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll fact[1000010], inv[1000010], mod = 1e9 + 7;

ll fexpo(ll x, ll y) {
  ll ret = 1;
  while (y) {
    if (y & 1)
      ret = (ret * x) % mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ret;
}

void fac() {
  fact[0] = 1;
  for (ll i = 1; i < 1000010; i++)
    fact[i] = i * fact[i - 1] % mod;
  inv[1000009] = fexpo(fact[1000009], mod - 2);
  for (ll i = 1000008; i >= 0; i--)
    inv[i] = (i + 1) * inv[i + 1] % mod;
}

ll ncr(ll x, ll y) {
  if (y > x)
    return 0;
  ll cnt = fact[x] * inv[x - y] % mod * inv[y] % mod;
  return cnt;
}

void solve() {
  ll k, n;
  string s;
  cin >> k >> s;
  n = s.length();
  ll cnt = 0;
  for (ll i = 0; i <= k; i++) {
    cnt +=
        fexpo(26, i) * fexpo(25, k - i) % mod * ncr(k - i + n - 1, n - 1) % mod;
  }
  cout << cnt % mod << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac();
  // int t;cin>>t;while(t--)
  solve();
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

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

template <typename T> T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while (n > 0) {
    if (n & 1)
      (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main() {
  COMinit();
  ll k;
  std::cin >> k;
  string s;
  std::cin >> s;

  ll n = s.size();
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += COM(n + i - 1, n - 1) * mod_pow((ll)26, (ll)k - i, MOD) % MOD *
           mod_pow((ll)25, (ll)i, MOD) % MOD;
    ans %= MOD;
  }

  std::cout << ans << std::endl;
}


Error: 0

Fixed submission:

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

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

template <typename T> T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while (n > 0) {
    if (n & 1)
      (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main() {
  COMinit();
  ll k;
  std::cin >> k;
  string s;
  std::cin >> s;

  ll n = s.size();
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += COM(n + i - 1, n - 1) * mod_pow((ll)26, (ll)k - i, MOD) % MOD *
           mod_pow((ll)25, (ll)i, MOD) % MOD;
    ans %= MOD;
  }

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

#include <bits/stdc++.h>
#define pii pair<ll, ll>
using namespace std;
typedef long long ll;
const ll modd = 1000000007;
ll n, k, fac[2000006];
string s;
ll qpow(ll a, ll b) {
  ll ans = 1, base = a;
  while (b) {
    if (b & 1)
      ans = ans * base % modd;
    b >>= 1, base = base * base % modd;
  }
  return ans;
}

ll C(ll n, ll m) {
  return fac[n] * qpow(fac[m], modd - 2) % modd * qpow(fac[n - m], modd - 2) %
         modd;
}
void solve() {
  ll ans = 0;
  for (int i = n; i <= n + k; i++)
    (ans += C(i - 1, n - 1) * qpow(25, i - n) % modd * qpow(26, n + k - i) %
            modd) %= modd;
  cout << ans;
}
void init() {
  n = s.size();
  fac[0] = 1;
  for (ll i = 1; i <= n + k; i++)
    fac[i] = fac[i - 1] * i % modd;
}
int main() {
  cin >> k >> s;
  init();
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pii pair<ll, ll>
using namespace std;
typedef long long ll;
const ll modd = 1000000007;
ll n, k;
string s;
ll qpow(ll a, ll b) {
  ll ans = 1, base = a;
  while (b) {
    if (b & 1)
      ans = ans * base % modd;
    b >>= 1, base = base * base % modd;
  }
  return ans;
}
ll fac(ll l, ll r) {
  ll ans = 1;
  for (ll i = l; i <= r; i++)
    (ans *= i) %= modd;
  return ans;
}
ll C(ll n, ll m) {
  return fac(n - m + 1, n) * qpow(fac(1, m), modd - 2) % modd;
}
void solve() {
  ll ans = 0;
  for (int i = n; i <= n + k; i++)
    (ans += C(i - 1, n - 1) * qpow(25, i - n) % modd * qpow(26, n + k - i) %
            modd) %= modd;
  cout << ans;
}
int main() {
  cin >> k >> s;
  n = s.size();
  solve();
  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

const int mod = 1e9 + 7;

long long mpow(long long a, int n) {
  if (n == 0)
    return 1;
  if (n == 1)
    return a;
  if (n % 2)
    return (a * (mpow(a, n - 1) % mod)) % mod;
  else {
    long long tmp = mpow(a, n / 2) % mod;
    return tmp * tmp % mod;
  }
}

const int MAX = 2000006;
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 nCk(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() {
  int k;
  string s;
  cin >> k >> s;

  COMinit();

  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    ans = (ans + mpow(26, i) * mpow(25, k - i) % mod *
                     (nCk(s.size() + k - 1 - i, s.size() - 1)) % mod) %
          mod;
  }

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


Error: 0

Fixed submission:

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

const int mod = 1e9 + 7;

long long mpow(long long a, int n) {
  if (n == 0)
    return 1;
  if (n == 1)
    return a;
  if (n % 2)
    return (a * (mpow(a, n - 1) % mod)) % mod;
  else {
    long long tmp = mpow(a, n / 2) % mod;
    return tmp * tmp % mod;
  }
}

const int MAX = 1000001;
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 nCk(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() {
  int k;
  string s;
  cin >> k >> s;

  COMinit();

  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    ans = (ans + mpow(26, i) * mpow(25, k - i) % mod *
                     (nCk(s.size() + k - 1 - i, s.size() - 1)) % mod) %
          mod;
  }

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

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
vector<long> fact_inv, inv, Com;
void init_nCk(int n, int k) {
  fact_inv.resize(k + 1);
  inv.resize(k + 1);
  fact_inv[0] = fact_inv[1] = inv[1] = 1;
  for (int i = 2; i <= k; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
  Com.resize(k + 1);
  Com[0] = 1;
  for (int i = 1; i <= k; i++) {
    Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
  }
}
int K, i, a;
long x = 1, ans = 0;
int nCk(int k) { return Com[k]; }
int main() {
  string S;
  cin >> K >> S;
  a = K + S.size();
  init_nCk(a, K);
  for (i = 0; i <= K; i++) {
    ans += x * nCk(i);
    ans %= MOD;
    x = x * 25 % MOD;
  }
  cout << ans << endl;
}

Error: -6
malloc(): corrupted top size


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
vector<long> fact_inv, inv, Com;
void init_nCk(int n, int k) {
  fact_inv.resize(k);
  inv.resize(k);
  fact_inv[0] = fact_inv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= k; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
  }
  Com.resize(k);
  Com[0] = 1;
  for (int i = 1; i <= k; i++) {
    Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
  }
}
int K, i, a;
long x = 1, ans = 0;
int nCk(int k) { return Com[k]; }
int main() {
  string S;
  cin >> K >> S;
  a = K + S.size();
  init_nCk(a, K);
  for (i = 0; i <= K; i++) {
    ans += x * nCk(i);
    ans %= MOD;
    x = x * 25 % MOD;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

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

const int64_t MAX = 2e+6 + 10;
const int64_t MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int64_t 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;
  }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t 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() {
  int64_t K;
  string S;
  cin >> K;
  cin >> S;
  int64_t N = S.size();

  // 前処理
  COMinit();

  vector<int64_t> POW26(K + 10), POW25(K + 10);
  POW26[0] = 1;
  POW25[0] = 1;
  for (int64_t i = 1; i < K + 10; ++i) {
    POW25[i] = POW25[i - 1] * 25 % MOD;
    POW26[i] = POW26[i - 1] * 26 % MOD;
  }

  int64_t sum = 0;
  for (int64_t k = 0; k <= K; ++k) {
    sum = (sum +
           (COM(N + K - k - 1, N - 1) * POW26[k]) % MOD * POW25[K - k] % MOD) %
          MOD;
  }

  if (sum < 0)
    sum += MOD;

  cout << sum << endl;

  return 0;
}


Error: 0

Fixed submission:

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

const int64_t MAX = 1e+6 + 10;
const int64_t MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int64_t 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;
  }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t 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() {
  int64_t K;
  string S;
  cin >> K;
  cin >> S;
  int64_t N = S.size();

  // 前処理
  COMinit();

  vector<int64_t> POW26(K + 10), POW25(K + 10);
  POW26[0] = 1;
  POW25[0] = 1;
  for (int64_t i = 1; i < K + 10; ++i) {
    POW25[i] = POW25[i - 1] * 25 % MOD;
    POW26[i] = POW26[i - 1] * 26 % MOD;
  }

  int64_t sum = 0;
  for (int64_t k = 0; k <= K; ++k) {
    sum = (sum +
           (COM(N + K - k - 1, N - 1) * POW26[k]) % MOD * POW25[K - k] % MOD) %
          MOD;
  }

  if (sum < 0)
    sum += MOD;

  cout << sum << endl;

  return 0;
}
Problem p02632 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ar array

int k;
string s;
ll mod = 1000000007;

inline long long mpow(long long b, long long ex) {
  if (b == 1)
    return 1;
  if (b == 0)
    return 1;
  long long r = 1;
  while (ex) {
    if (ex & 1)
      r = (r * b) % mod;
    ex = ex >> 1;
    b = (b * b) % mod;
  }
  return r;
}

ll choose(ll n, ll m) {

  ll ret = 1;
  for (ll i = n; i > n - m; i--) {
    ret = ret * i;
    ret = ret % mod;
  }

  ll k = 1;
  for (ll i = 1; i <= m; i++) {
    k = k * i;
    k = k % mod;
  }

  // inverse k since mod is prime
  ll phi = mod - 2;
  ll inv = 1;
  while (phi > 0) {
    if (phi & 1)
      inv = inv * k;
    inv = inv % mod;
    k = k * k;
    k = k % mod;
    phi = phi >> 1;
  }

  ret = ret * inv;
  ret = ret % mod;

  return ret;
}

void solve() {

  cin >> k;
  cin >> s;

  int size = s.length();

  ll ans = 1;
  ll val = 1;
  ll n = k + size;
  for (int i = 0; i < n; i++) {
    ans = ans * 26;
    ans = ans % mod;

    val = val * 25;
    val = val % mod;
  }

  ll inv = 280000002;

  ll cur;
  ll choose = 1;
  for (int i = 0; i < size; i++) {
    cur = choose * val;
    choose = choose * (n - i);
    choose = choose % mod;

    choose = choose * mpow(i + 1, mod - 2);
    choose = choose % mod;
    // cout << "i = " << i << " cho : " << choose << endl;

    cur = cur % mod;
    ans = ans - cur;
    ans = ans % mod;
    if (ans < 0)
      ans += mod;
    val = val * inv;
    val = val % mod;
  }
  cout << ans << endl;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  solve();
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ar array

int k;
string s;
ll mod = 1000000007;

ll choose(ll n, ll m) {

  ll ret = 1;
  for (ll i = n; i > n - m; i--) {
    ret = ret * i;
    ret = ret % mod;
  }

  ll k = 1;
  for (ll i = 1; i <= m; i++) {
    k = k * i;
    k = k % mod;
  }

  // inverse k since mod is prime
  ll phi = mod - 2;
  ll inv = 1;
  while (phi > 0) {
    if (phi & 1)
      inv = inv * k;
    inv = inv % mod;
    k = k * k;
    k = k % mod;
    phi = phi >> 1;
  }

  ret = ret * inv;
  ret = ret % mod;

  return ret;
}

void solve() {

  cin >> k;
  cin >> s;

  int size = s.length();

  ll ans = 1;
  ll val = 1;
  ll n = k + size;
  for (int i = 0; i < n; i++) {
    ans = ans * 26;
    ans = ans % mod;

    val = val * 25;
    val = val % mod;
  }

  ll inv = 280000002;

  ll cur;
  for (int i = 0; i < size; i++) {
    cur = choose(n, i) * val;
    cur = cur % mod;
    ans = ans - cur;
    ans = ans % mod;
    if (ans < 0)
      ans += mod;
    val = val * inv;
    val = val % mod;
  }
  cout << ans << endl;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;

const int MAX = 2e6 + 1; // nCrのnのMAX+1
ll 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) { // 1≦k≦n≦10^7
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// Add cominit(); in main function.

ll rui(ll a, ll n) {
  ll ans = 1;
  while (n > 0) {
    if (n & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    n /= 2;
  }
  return ans;
}

int main() {
  cominit();
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  k = k + n;
  ll ans = 0;
  for (int i = n; i <= k; i++) {
    ans += rui(26, k - i) * com(i - 1, n - 1) % mod * rui(25, i - n) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;

const int MAX = 200001; // nCrのnのMAX+1
ll 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) { // 1≦k≦n≦10^7
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// Add cominit(); in main function.

ll rui(ll a, ll n) {
  ll ans = 1;
  while (n > 0) {
    if (n & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    n /= 2;
  }
  return ans;
}

int main() {
  cominit();
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  k = k + n;
  ll ans = 0;
  for (int i = n; i <= k; i++) {
    ans += rui(26, k - i) * com(i - 1, n - 1) % mod * rui(25, i - n) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}
Problem p02632 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define rrep(i, n) RREP(i, n - 1, 0)
#define all(v) v.begin(), v.end()
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_N; i++) {
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    fac[i] = fac[i - 1] * (ll)i % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if (n < 0)
    return 0;
  else if (n < r)
    return 0;
  else
    return (fac[n] * finv[n - r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);            // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}
ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while (N > 0) {
    if (N % 2 == 1)
      (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K;
  string S;
  cin >> K >> S;
  ll N = S.size();
  make();
  ll ans = 0;
  rep(i, K + 1) {
    ll k = K - i;
    (ans +=
     comb(k + N - 1, N - 1) * modpow(25, k) % mod * modpow(26, i) % mod) %= mod;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define rrep(i, n) RREP(i, n - 1, 0)
#define all(v) v.begin(), v.end()
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

#define MAX_N 200005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX_N; i++) {
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    fac[i] = fac[i - 1] * (ll)i % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if (n < 0)
    return 0;
  else if (n < r)
    return 0;
  else
    return (fac[n] * finv[n - r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);            // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}
ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while (N > 0) {
    if (N % 2 == 1)
      (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K;
  string S;
  cin >> K >> S;
  ll N = S.size();
  make();
  ll ans = 0;
  rep(i, K + 1) {
    ll k = K - i;
    (ans +=
     comb(k + N - 1, N - 1) * modpow(25, k) % mod * modpow(26, i) % mod) %= mod;
  }
  cout << ans << endl;
  return 0;
}