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

#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\\n"
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
template <template <typename, typename...> class ContainerType,
          typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c) {
  for (const auto &v : c)
    cout << v << ' ';
  cout << '\\n';
}
void print() { cout << '\\n'; }
template <typename T, typename... Args> void print(T a, Args... args) {
  cout << a << " ";
  print(args...);
}
lli llipower(lli x, lli y, lli p = LLONG_MAX) {
  lli res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

// 8====================================D
lli fact[(int)2e6 + 20];
lli nck(lli n, lli k) {
  lli num = fact[n];
  num = (num * llipower(fact[k], mod - 2, mod)) % mod;
  num = (num * llipower(fact[n - k], mod - 2, mod)) % mod;
  return num;
}
lli rec(lli n, lli k) {
  lli ans = 0;
  for (lli i = 0; i <= n - k; i++) {
    ans += (nck(n, i + k) * llipower(25, n - k - i, mod));
    ans %= mod;
  }
  return ans;
}

int main() {
  memset(fact, 0, sizeof(fact));
  fact[1] = 1;
  fact[0] = 1;
  // print(fact[10], fact[2], nck(10, 2));
  for (lli i = 2; i <= 2e6 + 10; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  lli n;
  cin >> n;
  string s;
  cin >> s;
  lli x = s.size();
  // print(fact[10],fact[2],nck(10,2));
  cout << rec(x + n, x) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\\n"
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
template <template <typename, typename...> class ContainerType,
          typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c) {
  for (const auto &v : c)
    cout << v << ' ';
  cout << '\\n';
}
void print() { cout << '\\n'; }
template <typename T, typename... Args> void print(T a, Args... args) {
  cout << a << " ";
  print(args...);
}
lli llipower(lli x, lli y, lli p = LLONG_MAX) {
  lli res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

// 8====================================D
lli fact[(int)1e6 + 20];
lli nck(lli n, lli k) {
  lli num = fact[n];
  num = (num * llipower(fact[k], mod - 2, mod)) % mod;
  num = (num * llipower(fact[n - k], mod - 2, mod)) % mod;
  return num;
}
lli rec(lli n, lli k) {
  lli ans = 0;
  for (lli i = 0; i <= n - k; i++) {
    ans += (nck(n, i + k) * llipower(25, n - k - i, mod));
    ans %= mod;
  }
  return ans;
}

int main() {
  memset(fact, 0, sizeof(fact));
  fact[1] = 1;
  fact[0] = 1;
  // print(fact[10], fact[2], nck(10, 2));
  for (lli i = 2; i <= 1e6 + 10; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  lli n;
  cin >> n;
  string s;
  cin >> s;
  lli x = s.size();
  // print(fact[10],fact[2],nck(10,2));
  cout << rec(x + n, x) << endl;
}