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

#pragma warning(disable : 4996)
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1001001001;

const int mod = 100000;

/*
??????????????°???????????°?????????????????§???,??¶????????????????????§????????´????????????????????????????????????????????????,??????????????´???????????§??????????????´?????????????°????????????§,??\\???????????¶????????£?????????????????????
 ??¢ ????????´???????????? N ??? N
??????????????????????????????????????????????????????????????£??´??°??????????????????????????????????????????????????´??°?????¨?????°?????????
??¢ ????????????????????????????????´??°??? 1 ??\\??? M ??\\?????§?????????
??¢ ????????´??????????????????????????????N??N????????´??°???????¨???? S
??§?????????
??¢
????????????????????¨????????????????????????????????£?????´??°????????????????????§?????????
??¢
????????????????????´??°???????????????????????????????????????????????´??°???????????§?????????

??\\????????? N = 5, M = 50, S = 685
?????¨??????????????´?????????????????§?????????



????????????????????????????????¶????????????????????´??????????????§????????????????????????????????????????????????????????????????????????2?????\\????????£????????????????????????????????¨?????§??????????????´?????????????????°????????§??????
100000 ??§?????£????????????????????????????????°????????????????????????

??\\???

 ??\\??????1???????????????, ???????????????????????´????????????????????? N
(1???N???7), ????????????????????????????????´??°????????? M
(1???M???2000),????????´????????????????????????????????´??°???????¨? S
(1???S???3000)
?????¨???3????????£??´??°????????????????????§??????????????????????????????,
???????????????????????\\???????????????????????????????????¶????????????????????´????????????1?????\\??????????????¨?????§?????????

??????

???????????¨?????§??????????????´?????????????????°????????§?????? 100000
??§?????£???????????????????????????
*/

int main() {
  int N, M, S;
  int dp[66][3003];
  const int mod = 100000;
  while (1) {
    scanf("%d %d %d", &N, &M, &S);
    if (N == 0)
      break;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int k = 1; k < M + 1; k++) {
      for (int i = N * N; i > 0; i--) {
        for (int j = 1; j < S + 1; j++) {
          if (j - k > -1)
            dp[i][j] += dp[i - 1][j - k];
          dp[i][j] %= mod;
        }
      }
    }
    printf("%d\\n", dp[N * N][S] % mod);
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <math.h>
#include <queue>

using namespace std;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < n; i++)

int N, M, S;
const int mod = 100000;

int main() {
  while (1) {
    scanf("%d %d %d", &N, &M, &S);
    if (N == 0 && M == 0 && S == 0)
      break;
    int dp[2002][3002];
    rep(i, M + 1) {
      rep(j, S + 1) {
        if (j == 0) {
          dp[i][j] = (i == 0 ? 1 : 0);
        }
        if (j - i > -1) {
          dp[i][j] += dp[j - i][j - i] % mod;
        }
        if (i != 0)
          dp[i][j] += dp[i - 1][j] % mod;
        dp[i][j] %= mod;
      }
    }
    int ans = 0;
    rep(i, M + 1) ans += dp[i][S] % mod;
    printf("%d\\n", ans % mod);
  }
  return 0;
}