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

#include <bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin {
private:
  int _ch, _f;

public:
  inline fastin &operator>>(char &c) {
    c = getchar();
    return *this;
  }
  template <typename _Tp> inline fastin &operator>>(_Tp &_x) {
    _x = 0;
    while (!isdigit(_ch))
      _f |= (_ch == 45), _ch = getchar();
    while (isdigit(_ch))
      _x = (_x << 1) + (_x << 3) + (_ch ^ 48), _ch = getchar();
    _f && (_x = -_x, _f = 0);
    return *this;
  }
  fastin() { _ch = _f = 0; }
} fin;
class fastout {
#define endl '\\n'
private:
  int _num[32], _head;

public:
  inline fastout &operator<<(char c) {
    putchar(c);
    return *this;
  }
  template <typename _Tp> inline fastout &operator<<(_Tp _x) {
    _Tp _k;
    if (_x == 0) {
      putchar('0');
      return *this;
    }
    if (_x < 0)
      putchar('-'), _x = -_x;
    while (_x > 0)
      _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,
      _x = _k;
    while (_head > 0)
      putchar(_num[_head]), --_head;
    return *this;
  }
  fastout() { _head = 0; }
} fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn = 2000004;
const int mod = 1000000007, inf = 1000000007;

std::string s;
inline ll powmod(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      (res *= a) %= mod;
    (a *= a) %= mod, b >>= 1;
  }
  return res;
}
ll fact[maxn], invfact[maxn];
inline void init() {
  fact[0] = invfact[0] = 1;
  for (rgi i = 1; i < maxn; ++i)
    fact[i] = fact[i - 1] * i % mod, invfact[i] = powmod(fact[i], mod - 2);
}
inline ll C(ll n, ll m) {
  return fact[n] * invfact[m] % mod * invfact[n - m] % mod;
}
signed main() {
  int n;
  fin >> n;
  std::cin >> s;
  init();
  int len = s.length() - 1;
  ll ans = 0;
  for (rgi i = 0; i <= n; ++i)
    (ans += powmod(26, i) * powmod(25, n - i) % mod * C(n - i + len, len)) %=
        mod;
  fout << ans;
  return 0;
}
// ----------------------------
// by imzzy


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin {
private:
  int _ch, _f;

public:
  inline fastin &operator>>(char &c) {
    c = getchar();
    return *this;
  }
  template <typename _Tp> inline fastin &operator>>(_Tp &_x) {
    _x = 0;
    while (!isdigit(_ch))
      _f |= (_ch == 45), _ch = getchar();
    while (isdigit(_ch))
      _x = (_x << 1) + (_x << 3) + (_ch ^ 48), _ch = getchar();
    _f && (_x = -_x, _f = 0);
    return *this;
  }
  fastin() { _ch = _f = 0; }
} fin;
class fastout {
#define endl '\\n'
private:
  int _num[32], _head;

public:
  inline fastout &operator<<(char c) {
    putchar(c);
    return *this;
  }
  template <typename _Tp> inline fastout &operator<<(_Tp _x) {
    _Tp _k;
    if (_x == 0) {
      putchar('0');
      return *this;
    }
    if (_x < 0)
      putchar('-'), _x = -_x;
    while (_x > 0)
      _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,
      _x = _k;
    while (_head > 0)
      putchar(_num[_head]), --_head;
    return *this;
  }
  fastout() { _head = 0; }
} fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn = 1000004;
const int mod = 1000000007, inf = 1000000007;

std::string s;
inline ll powmod(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      (res *= a) %= mod;
    (a *= a) %= mod, b >>= 1;
  }
  return res;
}
ll fact[maxn], invfact[maxn];
inline void init() {
  fact[0] = invfact[0] = 1;
  for (rgi i = 1; i < maxn; ++i)
    fact[i] = fact[i - 1] * i % mod, invfact[i] = powmod(fact[i], mod - 2);
}
inline ll C(ll n, ll m) {
  return fact[n] * invfact[m] % mod * invfact[n - m] % mod;
}
signed main() {
  int n;
  fin >> n;
  std::cin >> s;
  init();
  int len = s.length() - 1;
  ll ans = 0;
  for (rgi i = 0; i <= n; ++i)
    (ans += powmod(26, i) * powmod(25, n - i) % mod * C(n - i + len, len)) %=
        mod;
  fout << ans;
  return 0;
}
// ----------------------------
// by imzzy