Problem p02992 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9 + 7)
#define inf (int)(3e18 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(v) v.begin(), v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define vecunique(vec)                                                         \
  sort(vec.begin(), vec.end());                                                \
  decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());        \
  vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return x > 1;
}
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int kai(int x, int y) {
  int res = 1;
  for (int i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= mod;
  }
  return res;
}
int mod_pow(int x, int y) {
  int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
int comb(int x, int y) {
  if (y > x)
    return 0;
  return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, k;
int dp[100][100000];
int shu, cnt[100000];
signed main() {
  cin >> n >> k;
  for (int i = 1; i <= n;) {
    if (n / i != n / (i + 1)) {
      cnt[shu++] = 1;
      i++;
    } else {
      int memo = n / (n / i) + 1;
      cnt[shu++] = memo - i;
      i = memo;
    }
  }
  dp[0][1] = 1;
  int sum[100000];
  fill(sum, sum + 100000, 1);
  rep(i, k) {
    rep(j, shu + 1) { dp[i + 1][j] = sum[shu - j - 1] * cnt[j] % mod; }
    fill(sum, sum + 100000, 0);
    rep(j, shu + 1) {
      sum[j] += dp[i + 1][j];
      sum[j] %= mod;
      sum[j + 1] += sum[j];
    }
  }
  int ans = 0;
  cout << sum[shu] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9 + 7)
#define inf (int)(3e18 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(v) v.begin(), v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define vecunique(vec)                                                         \
  sort(vec.begin(), vec.end());                                                \
  decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());        \
  vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return x > 1;
}
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int kai(int x, int y) {
  int res = 1;
  for (int i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= mod;
  }
  return res;
}
int mod_pow(int x, int y) {
  int res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
int comb(int x, int y) {
  if (y > x)
    return 0;
  return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, k;
int dp[105][100000];
int shu, cnt[100000];
signed main() {
  cin >> n >> k;
  for (int i = 1; i <= n;) {
    if (n / i != n / (i + 1)) {
      cnt[shu++] = 1;
      i++;
    } else {
      int memo = n / (n / i) + 1;
      cnt[shu++] = memo - i;
      i = memo;
    }
  }
  dp[0][1] = 1;
  int sum[100000];
  fill(sum, sum + 100000, 1);
  rep(i, k) {
    rep(j, shu + 1) { dp[i + 1][j] = sum[shu - j - 1] * cnt[j] % mod; }
    fill(sum, sum + 100000, 0);
    rep(j, shu + 1) {
      sum[j] += dp[i + 1][j];
      sum[j] %= mod;
      sum[j + 1] += sum[j];
    }
  }
  int ans = 0;
  cout << sum[shu] << endl;
}