Problem p03170 (C++)

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

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))

#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7

#define print2D(h, w, arr)                                                     \
  REP(i, h) {                                                                  \
    REP(j, w) cout << arr[i][j] << " ";                                        \
    cout << endl;                                                              \
  }
#define print_line(vec, n)                                                     \
  {                                                                            \
    for (int i = 0; i < (n - 1); i++)                                          \
      cout << (vec)[i] << " ";                                                 \
    cout << (vec)[(n)-1] << endl;                                              \
  }
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
  cout << first << " ";
  print(rest...);
}
struct PreMain {
  PreMain() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} premain;

/* 残りi枚で回ってきたときその人が勝てるかどうか */
bool dp[10001];

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  REPN(i, 1, K + 1) REP(j, N) { dp[i] |= (a[j] <= i) && (!dp[i - a[j]]); }

  if (dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}

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

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))

#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7

#define print2D(h, w, arr)                                                     \
  REP(i, h) {                                                                  \
    REP(j, w) cout << arr[i][j] << " ";                                        \
    cout << endl;                                                              \
  }
#define print_line(vec, n)                                                     \
  {                                                                            \
    for (int i = 0; i < (n - 1); i++)                                          \
      cout << (vec)[i] << " ";                                                 \
    cout << (vec)[(n)-1] << endl;                                              \
  }
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
  cout << first << " ";
  print(rest...);
}
struct PreMain {
  PreMain() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} premain;

/* 残りi枚で回ってきたときその人が勝てるかどうか */
bool dp[100001];

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  REPN(i, 1, K + 1) REP(j, N) { dp[i] |= (a[j] <= i) && (!dp[i - a[j]]); }

  if (dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}