Problem p02992 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define mod 1000000007
#define FOR(x, to) for (int x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define long long long
inline int rei() {
  int x;
  cin >> x;
  return x;
}
inline long rel() {
  long x;
  cin >> x;
  return x;
}
inline string res() {
  string x;
  cin >> x;
  return x;
}
//-------------------------------------------------------
long DP[101][50000];
void Calc() {
  long N = rei();
  int K = rei();
  vector<long> C;
  {
    int i;
    int sq;
    for (i = 1; i * i <= N; i++) {
      C.push_back(1);
    }
    sq = i - 1;
    if (N / sq - sq != 0) {
      C.push_back(N / sq - sq);
    }
    for (i = sq; i >= 2; i--) {
      C.push_back(N / (i - 1) - N / i);
    }
  }
  DP[0][0] = 1;
  for (int i = 1; i <= K; i++) {
    long sum = 0;
    for (int j = C.size() - 1; j >= 0; j--) {
      sum += DP[i - 1][C.size() - 1 - j];
      sum %= mod;
      DP[i][j] = sum * C[j] % mod;
    }
  }
  long ans = 0;
  for (int i = 0; i < C.size(); i++) {
    ans += DP[K][i];
  }
  ans %= mod;
  cout << ans << endl;
}
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  cout.tie(0);
  Calc();
  return 0;
}

Fixed submission:
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define mod 1000000007
#define FOR(x, to) for (int x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define long long long
inline int rei() {
  int x;
  cin >> x;
  return x;
}
inline long rel() {
  long x;
  cin >> x;
  return x;
}
inline string res() {
  string x;
  cin >> x;
  return x;
}
//-------------------------------------------------------
long DP[101][100000];
void Calc() {
  long N = rei();
  int K = rei();
  vector<long> C;
  {
    int i;
    int sq;
    for (i = 1; i * i <= N; i++) {
      C.push_back(1);
    }
    sq = i - 1;
    if (N / sq - sq != 0) {
      C.push_back(N / sq - sq);
    }
    for (i = sq; i >= 2; i--) {
      C.push_back(N / (i - 1) - N / i);
    }
  }
  DP[0][0] = 1;
  for (int i = 1; i <= K; i++) {
    long sum = 0;
    for (int j = C.size() - 1; j >= 0; j--) {
      sum += DP[i - 1][C.size() - 1 - j];
      sum %= mod;
      DP[i][j] = sum * C[j] % mod;
    }
  }
  long ans = 0;
  for (int i = 0; i < C.size(); i++) {
    ans += DP[K][i];
  }
  ans %= mod;
  cout << ans << endl;
}
int main(int argc, char **argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  cout.tie(0);
  Calc();
  return 0;
}