Problem p02632 (C++)

Buggy submission (status: Runtime Error):
// Coded by Abhijay Mitra
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <vector>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(), std::unique(v.begin(), v.end()));
#define timer                                                                  \
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int, int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, b, a) for (int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
using namespace std;
const int N = 1e6 + 10;
const int inf = /*0x3f3f3f3f*/ 1e18 + 10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9 + 7; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int mul(int a, int b) { return ((a % M) * (b % M)) % M; }
int add(int a, int b) { return ((a % M) + (b % M)) % M; }
ll powM(ll a, int n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = x * a % M;
    a = a * a % M;
    n >>= 1;
  }
  return x;
}
int invM(int x) { return powM(x, M - 2); }
int f[N], b[N];
void binomialCoeff(int n) {
  f[0] = b[0] = 1;
  rep(i, 1, N - 1) {
    f[i] = mul(f[i - 1], i);
    b[i] = invM(f[i]);
  }
  // per(i,N-2,0)b[i]=mul(b[i+1],i+1);
  // rep(i,1,n){
  //   C[i]=mul(mul(f[n],b[n-i]),b[i]);
  // }
}
int C(int n, int i) {
  if (i < 0 or n < i)
    return 0;
  return mul(mul(f[n], b[n - i]), b[i]);
}
void solve() {
  int n, k;
  cin >> k;
  string s;
  cin >> s;
  n = s.length();
  binomialCoeff(n + k);
  int ans = 0;
  rep(i, n, n + k) { ans = add(ans, mul(powM(25, n + k - i), C(n + k, i))); }
  cout << ans;
}
int32_t main() {
  ibs;
  cti;
  solve()
      /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx = 0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case
  // "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Fixed submission:
// Coded by Abhijay Mitra
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <vector>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(), std::unique(v.begin(), v.end()));
#define timer                                                                  \
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int, int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, b, a) for (int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
using namespace std;
const int N = 2e6 + 10;
const int inf = /*0x3f3f3f3f*/ 1e18 + 10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9 + 7; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int mul(int a, int b) { return ((a % M) * (b % M)) % M; }
int add(int a, int b) { return ((a % M) + (b % M)) % M; }
ll powM(ll a, int n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = x * a % M;
    a = a * a % M;
    n >>= 1;
  }
  return x;
}
int invM(int x) { return powM(x, M - 2); }
int f[N], b[N];
void binomialCoeff(int n) {
  f[0] = b[0] = 1;
  rep(i, 1, N - 1) {
    f[i] = mul(f[i - 1], i);
    b[i] = invM(f[i]);
  }
  // per(i,N-2,0)b[i]=mul(b[i+1],i+1);
  // rep(i,1,n){
  //   C[i]=mul(mul(f[n],b[n-i]),b[i]);
  // }
}
int C(int n, int i) {
  if (i < 0 or n < i)
    return 0;
  return mul(mul(f[n], b[n - i]), b[i]);
}
void solve() {
  int n, k;
  cin >> k;
  string s;
  cin >> s;
  n = s.length();
  binomialCoeff(n + k);
  int ans = 0;
  rep(i, n, n + k) { ans = add(ans, mul(powM(25, n + k - i), C(n + k, i))); }
  cout << ans;
}
int32_t main() {
  ibs;
  cti;
  solve()
      /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx = 0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case
  // "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}