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

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(2e6 + 5)
#define mod (ll)(1e9 + 7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define pi pair<ll, ll>
#define vvpi vector<vector<pi>>
#define vpi vector<pi>
#define vppi vector<pair<ll, pi>>
#define vs vector<string>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v, n) v.clear(), v.resize(n + 1, 0)
#define print(v)                                                               \\
  for (ll it = 0; it < v.size(); it++)                                         \\
    cout << v[it] << " ";                                                      \\
  cout << endl
#define printp(v)                                                              \\
  for (ll it = 0; it < v.size(); it++)                                         \\
  cout << v[it].first << " " << v[it].second << endl
using namespace std;
vi fact(mxn, 1);
ll powe(ll x, ll y) {
  ll s = 1;
  while (y) {
    if (y % 2)
      s = (s * x) % mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return s;
}
ll ncr(ll n, ll r) {
  ll den = (powe(fact[r], mod - 2) * powe(fact[n - r], mod - 2)) % mod;
  return (fact[n] * den) % mod;
}
int main() {
  fast;
  int k;
  string s;
  cin >> k >> s;
  int n = s.size() + k, i;
  for (i = 1; i <= n; i++)
    fact[i] = (fact[i - 1] * i) % mod;
  ll c = powe(26, n);
  for (i = 0; i < (int)s.size(); i++) {
    ll x = (powe(25, n - i) * ncr(n, i)) % mod;
    c = (c - x + mod) % mod;
  }
  cout << c << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5 + 5)
#define mod (ll)(1e9 + 7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define pi pair<ll, ll>
#define vvpi vector<vector<pi>>
#define vpi vector<pi>
#define vppi vector<pair<ll, pi>>
#define vs vector<string>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v, n) v.clear(), v.resize(n + 1, 0)
#define print(v)                                                               \\
  for (ll it = 0; it < v.size(); it++)                                         \\
    cout << v[it] << " ";                                                      \\
  cout << endl
#define printp(v)                                                              \\
  for (ll it = 0; it < v.size(); it++)                                         \\
  cout << v[it].first << " " << v[it].second << endl
using namespace std;
vi fact(mxn, 1);
ll powe(ll x, ll y) {
  ll s = 1;
  while (y) {
    if (y % 2)
      s = (s * x) % mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return s;
}
ll ncr(ll n, ll r) {
  ll den = (powe(fact[r], mod - 2) * powe(fact[n - r], mod - 2)) % mod;
  return (fact[n] * den) % mod;
}
int main() {
  fast;
  int k;
  string s;
  cin >> k >> s;
  int n = s.size() + k, i;
  for (i = 1; i <= n; i++)
    fact[i] = (fact[i - 1] * i) % mod;
  ll c = powe(26, n);
  for (i = 0; i < (int)s.size(); i++) {
    ll x = (powe(25, n - i) * ncr(n, i)) % mod;
    c = (c - x + mod) % mod;
  }
  cout << c << endl;
}