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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define oset                                                                   \\
  tree<pair<ll, ll>, null_type, less_equal<pair<ll, ll>>, rb_tree_tag,         \\
       tree_order_statistics_node_update>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt                                                                   \\
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC       \\
       << "ms\\n"

ll po[3000005][2], fac[3000005];

ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

ll inv(ll n, ll p) { return power(n, p - 2, p); }

ll ncr(ll n, ll r) {
  ll p = A;
  if (r == 0)
    return 1;
  return (fac[n] * inv(fac[r], p) % p * inv(fac[n - r], p) % p) % p;
}

int main() {
  FAST;
  fac[0] = 1;
  po[0][0] = 1;
  po[0][1] = 1;
  for (int i = 1; i < 3000005; i++) {
    po[i][0] = (po[i - 1][0] * 26) % A;
    po[i][1] = (po[i - 1][1] * 25) % A;
    fac[i] = (fac[i - 1] * i) % A;
  }
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll k = s.length();
  ll ans = po[n + k][0];
  for (int i = 0; i < k; i++) {
    ll x = (ncr(n + k, i) * po[n + k - i][1]) % A;
    ans = (ans - x) % A;
  }
  ans += A;
  cout << (ans % A);
  subt;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define oset                                                                   \\
  tree<pair<ll, ll>, null_type, less_equal<pair<ll, ll>>, rb_tree_tag,         \\
       tree_order_statistics_node_update>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt                                                                   \\
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC       \\
       << "ms\\n"

ll po[1000005][2], fac[1000005];

ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

ll inv(ll n, ll p) { return power(n, p - 2, p); }

ll ncr(ll n, ll r) {
  ll p = A;
  if (r == 0)
    return 1;
  return (fac[n] * inv(fac[r], p) % p * inv(fac[n - r], p) % p) % p;
}

int main() {
  FAST;
  fac[0] = 1;
  po[0][0] = 1;
  po[0][1] = 1;
  for (int i = 1; i < 1000005; i++) {
    po[i][0] = (po[i - 1][0] * 26) % A;
    po[i][1] = (po[i - 1][1] * 25) % A;
    fac[i] = (fac[i - 1] * i) % A;
  }
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll k = s.length();
  ll ans = po[n + k][0];
  for (int i = 0; i < k; i++) {
    ll x = (ncr(n + k, i) * po[n + k - i][1]) % A;
    ans = (ans - x) % A;
  }
  ans += A;
  cout << (ans % A);
  subt;
  return 0;
}