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

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i, k, n) for (ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<long long, long long> Pll;
typedef tuple<int, int, int> Tii;

ll mod = 1e9 + 7;

long long powm(long long a, long long b, long long mod = 1000000007) {
  if (b < 0)
    b += mod - 1;
  if (b > 0) {
    if (b % 2 == 1)
      return a * powm(a * a % mod, b / 2) % mod;
    else
      return powm(a * a % mod, b / 2) % mod;
  } else {
    return 1;
  }
}
long long modinv(long long a, long long m) {
  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;
}

int main() {
  ll k, l;
  string s;
  cin >> k >> s;
  l = s.size();
  vector<ll> x25(l + k + 2, 1), x26(l + k + 2, 1), con(l + k + 2, 1);
  rept(i, 1, l + k + 2) {
    x25[i] = x25[i - 1] * 25 % mod;
    x26[i] = x26[i - 1] * 26 % mod;
  }
  rept(i, l - 1, l + k + 2) {
    con[i + 1] = ((con[i] * (i + 1)) % mod) * modinv(i + 2 - l, mod) % mod;
  }
  ll sum = 0;
  rept(i, l, l + k + 1) {
    sum += con[i - 1] * x25[i - l] % mod * x26[l + k - i] % mod;
    sum %= mod;
  }
  cout << sum << endl;
  // cout<<x25<<x26<<con<<endl;
  return 0;
}

Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i, k, n) for (ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<long long, long long> Pll;
typedef tuple<int, int, int> Tii;

ll mod = 1e9 + 7;

long long powm(long long a, long long b, long long mod = 1000000007) {
  if (b < 0)
    b += mod - 1;
  if (b > 0) {
    if (b % 2 == 1)
      return a * powm(a * a % mod, b / 2) % mod;
    else
      return powm(a * a % mod, b / 2) % mod;
  } else {
    return 1;
  }
}
long long modinv(long long a, long long m) {
  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;
}

int main() {
  ll k, l;
  string s;
  cin >> k >> s;
  l = s.size();
  vector<ll> x25(l + k + 1, 1), x26(l + k + 1, 1), con(l + k + 1, 1);
  rept(i, 1, l + k + 1) {
    x25[i] = x25[i - 1] * 25 % mod;
    x26[i] = x26[i - 1] * 26 % mod;
  }
  rept(i, l - 1, l + k + 1) {
    con[i + 1] = ((con[i] * (i + 1)) % mod) * modinv(i + 2 - l, mod) % mod;
  }
  ll sum = 0;
  rept(i, l, l + k + 1) {
    sum += con[i - 1] * x25[i - l] % mod * x26[l + k - i] % mod;
    sum %= mod;
  }
  cout << sum << endl;
  // cout<<x25<<x26<<con<<endl;
  return 0;
}