Problem p02992 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x)                                                                  \
  int x;                                                                       \
  cin >> (x)
#define ii2(x, y)                                                              \
  int x, y;                                                                    \
  cin >> (x) >> (y)
#define ii3(x, y, z)                                                           \
  int x, y, z;                                                                 \
  cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x) ? ("Yes") : ("No")) << endl
#define YN(x) cout << ((x) ? ("YES") : ("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger() { cout << endl; }
template <typename A, typename... B> void logger(const A &a, const B &...b) {
  cout << a << " , ";
  logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

const int MAX_C = 100;
lint cmb[MAX_C][MAX_C];
void cmb_init() {
  cmb[0][0] = 1;
  repn(i, 50) rep(j, i + 1) {
    if (j == 0)
      cmb[i][0] = 1;
    else if (j == i)
      cmb[i][i] = 1;
    else
      cmb[i][j] = cmb[i - 1][j - 1] + cmb[i - 1][j];
  }
}

lint dp[101][40000];

int main() {
  lint n;
  int k;
  cin >> n >> k;

  vector<lint> c;
  for (lint i = 1; i * i <= n; i++) {
    lint j = n / i;
    c.push_back(i);
    c.push_back(j);
  }
  sort(all(c));
  int m = c.size();

  rep(j, m) dp[1][j] = c[j];
  for (int i = 2; i <= k; i++) {
    rep(j, m) {
      if (j == 0) {
        dp[i][0] = dp[i - 1][m - 1];
        continue;
      }
      dp[i][j] =
          (dp[i][j - 1] + ((c[j] - c[j - 1]) * dp[i - 1][m - j - 1]) % MOD) %
          MOD;
    }
  }
  out(dp[k][m - 1]);
}

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

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repn(i, n) for (int(i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for (int(i) = (n - 1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x)                                                                  \
  int x;                                                                       \
  cin >> (x)
#define ii2(x, y)                                                              \
  int x, y;                                                                    \
  cin >> (x) >> (y)
#define ii3(x, y, z)                                                           \
  int x, y, z;                                                                 \
  cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x) ? ("Yes") : ("No")) << endl
#define YN(x) cout << ((x) ? ("YES") : ("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger() { cout << endl; }
template <typename A, typename... B> void logger(const A &a, const B &...b) {
  cout << a << " , ";
  logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

const int MAX_C = 100;
lint cmb[MAX_C][MAX_C];
void cmb_init() {
  cmb[0][0] = 1;
  repn(i, 50) rep(j, i + 1) {
    if (j == 0)
      cmb[i][0] = 1;
    else if (j == i)
      cmb[i][i] = 1;
    else
      cmb[i][j] = cmb[i - 1][j - 1] + cmb[i - 1][j];
  }
}

lint dp[105][80000];

int main() {
  lint n;
  int k;
  cin >> n >> k;

  vector<lint> c;
  for (lint i = 1; i * i <= n; i++) {
    lint j = n / i;
    c.push_back(i);
    c.push_back(j);
  }
  sort(all(c));
  int m = c.size();

  rep(j, m) dp[1][j] = c[j];
  for (int i = 2; i <= k; i++) {
    rep(j, m) {
      if (j == 0) {
        dp[i][0] = dp[i - 1][m - 1];
        continue;
      }
      dp[i][j] =
          (dp[i][j - 1] + ((c[j] - c[j - 1]) * dp[i - 1][m - j - 1]) % MOD) %
          MOD;
    }
  }
  out(dp[k][m - 1]);
}