Problem p00097 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define erep(e, v) for (auto &&e : v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9 : (int)1e18)
#define EPS 0.0000000001
using namespace std;
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
template <typename Head, typename Value>
auto vectors(const Head &head, const Value &v) {
  return vector<Value>(head, v);
}
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vector<decltype(inner)>(x, inner);
}
template <class T> void join(T a) {
  for (auto itr : a) {
    if (itr != *a.begin())
      cout << " ";
    cout << itr;
  }
}
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pii>;
int W, H;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
signed main() {
  int n, s;
  auto dp = vectors(11, 1001, 0LL);
  // dp[i][j] := used i number, and the SUM is j
  dp[0][0] = 1;
  for (int num = 0; num <= 100; num++) {
    for (int k = 9; k >= 0; --k) {
      for (int crt = 0; crt <= 1000; crt++) {
        if (dp[k][crt] != 0 and crt + num <= 1000) {
          dp[k + 1][crt + num] += dp[k][crt];
        }
      }
    }
  }
  while (cin >> n >> s, n + s) {
    cout << dp[n][s] << endl;
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
int n, s;
ll ans = 0;
void dfs(int now, int hoge, vb flag) {
  if (hoge > n || now > s)
    return;
  if (now == s && hoge == n) {
    ans++;
    return;
  }
  rep(i, 101) if (flag[i]) {
    vb ujimatu = flag;
    ujimatu[i] = false;
    dfs(now + i, hoge + 1, ujimatu);
  }
}
int main() {
  while (cin >> n >> s, n + s) {
    ans = 0;
    vb flag(101, true);
    rep(i, 101) if (flag[i]) {
      vb ujimatu = flag;
      ujimatu[i] = false;
      dfs(i, 1, ujimatu);
    }
    cout << ans / 6 << endl;
  }
}