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

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define mp(a, b) make_pair((a), (b))
#define mt(a, b, c) make_tuple((a), (b), (c))
#define MOD 1000000007
long long modinv(long long a, long long m = MOD) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

typedef long long ll;
ll fact[2000005];
ll pw[2000005];
long long comb(long long n, long long r) {
  return (((fact[n] * modinv(fact[r])) % MOD) * modinv(fact[n - r])) % MOD;
}
int main() {
  fact[0] = 1;
  pw[0] = 1;
  for (int i = 1; i < 2000003; i++)
    fact[i] = (fact[i - 1] * i) % MOD;
  for (int i = 1; i < 2000003; i++)
    pw[i] = (pw[i - 1] * 25) % MOD;
  long long int k;
  string s;
  cin >> k >> s;
  ll sum = 0;
  ll ss = s.length();
  for (int i = ss; i <= ss + k; i++) {
    sum = (sum + comb(ss + k, i) * pw[ss + k - i]) % MOD;
  }
  cout << sum << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define mp(a, b) make_pair((a), (b))
#define mt(a, b, c) make_tuple((a), (b), (c))
#define MOD 1000000007
long long modinv(long long a, long long m = MOD) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

typedef long long ll;
ll fact[1000005];
ll pw[1000005];
long long comb(long long n, long long r) {
  return (((fact[n] * modinv(fact[r])) % MOD) * modinv(fact[n - r])) % MOD;
}
int main() {
  fact[0] = 1;
  pw[0] = 1;
  for (int i = 1; i < 1000003; i++)
    fact[i] = (fact[i - 1] * i) % MOD;
  for (int i = 1; i < 1000003; i++)
    pw[i] = (pw[i - 1] * 25) % MOD;
  long long int k;
  string s;
  cin >> k >> s;
  ll sum = 0;
  ll ss = s.length();
  for (int i = ss; i <= ss + k; i++) {
    sum = (sum + comb(ss + k, i) * pw[ss + k - i]) % MOD;
  }
  cout << sum << endl;
  return 0;
}