Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9 + 7;

typedef tuple<int, int, int> State; // operator< defined
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef double ld;

int main(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  int n, k, i;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; ++i)
    cin >> a[i];
  int dp[k + 1], j;
  memset(dp, 0, sizeof(dp));

  for (i = 1; i <= k; ++i) {
    for (j = 0; j < n; ++j) {
      if (a[j] > i)
        continue;
      if (dp[i - a[j]] == 0)
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";

#ifndef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)
#define mp make_pair
#define eb emplace_back
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9 + 7;

typedef tuple<int, int, int> State; // operator< defined
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef double ld;

int main(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n, k, i;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; ++i)
    cin >> a[i];
  int dp[k + 1], j;
  memset(dp, 0, sizeof(dp));

  for (i = 1; i <= k; ++i) {
    for (j = 0; j < n; ++j) {
      if (a[j] > i)
        continue;
      if (dp[i - a[j]] == 0)
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";

#ifndef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
  return 0;
}