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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, e) for (int i = (s); i < (e); i++)
#define pb(n) push_back((n))
#define mp(n, m) make_pair((n), (m))
#define all(r) r.begin(), r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e10;
const int mod = 1e9 + 7;
const double EPS = 1e-9;

ll dp[11][110][1010];

int n, s;

int main() {
  while (cin >> n >> s) {
    if (n == 0 && s == 0)
      break;
    ll ans = 0LL;

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= 100; j++) {
        for (int k = 0; k <= s; k++) {
          dp[i][j][k] = 0LL;
        }
      }
    }

    for (int i = 0; i <= min(s, 100); i++)
      dp[1][i][s - i] = 1;
    for (int i = 2; i <= n; i++) {       // i??????
      for (int j = 0; j <= 100; j++) {   // i???????????°???j
        for (int k = 0; k < j; k++) {    //???????????????????????°k
          for (int l = j; l <= s; l++) { //?????????l
                                         // if(dp[i-1][k][l] > 0){
            dp[i][j][l - j] += dp[i - 1][k][l];
            //}
          }
        }
      }
    }

    for (int i = 0; i <= 100; i++) {
      ans += dp[n][i][0];
    }

    cout << ans << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, e) for (int i = (s); i < (e); i++)
#define pb(n) push_back((n))
#define mp(n, m) make_pair((n), (m))
#define all(r) r.begin(), r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 100000000000LL;
const int mod = 1e9 + 7;
const double EPS = 1e-9;

int dp[10][110][1010];

int n, s;

int main() {
  while (cin >> n >> s) {
    if (n == 0 && s == 0)
      break;
    int ans = 0;

    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= 110; j++) {
        for (int k = 0; k <= 1010; k++) {
          dp[i][j][k] = 0;
        }
      }
    }

    for (int i = 0; i <= min(s, 100); i++)
      dp[1][i][s - i] = 1;
    for (int i = 2; i <= n; i++) {       // i??????
      for (int j = 0; j <= 100; j++) {   // i???????????°???j
        for (int k = 0; k < j; k++) {    //???????????????????????°k
          for (int l = j; l <= s; l++) { //?????????l
                                         // if(dp[i-1][k][l] > 0){
            dp[i][j][l - j] += dp[i - 1][k][l];
            //}
          }
        }
      }
    }

    for (int i = 0; i <= 100; i++) {
      ans += dp[n][i][0];
    }

    cout << ans << endl;
  }
}