Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define PI 3.1415926535897932384626433832795l
#define IOS                                                                    \
  ios ::sync_with_stdio(false);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define deci(n) cout << fixed << setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i, a, b) for (int i = a; i < b; i++)
#define ForA1(i, a, b) for (int i = b - 1; i >= a; i--)
#define ForB1(i, a, b) for (int i = b; i > a; i--)
#define ForB(i, a, b) for (int i = a; i <= b; i++)
#define INT_SIZE 18
#define maxn 310
#define Maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

int a[maxn], dp[maxn];

int main() {
  IOS;
  int n, k;
  cin >> n >> k;
  ForB(i, 1, n) cin >> a[i];
  ForB(i, 0, k) {
    ForB(j, 1, n) {
      if (i >= a[j] && !dp[i - a[j]]) {
        dp[i] = true;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << '\n';
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define PI 3.1415926535897932384626433832795l
#define IOS                                                                    \
  ios ::sync_with_stdio(false);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define deci(n) cout << fixed << setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i, a, b) for (int i = a; i < b; i++)
#define ForA1(i, a, b) for (int i = b - 1; i >= a; i--)
#define ForB1(i, a, b) for (int i = b; i > a; i--)
#define ForB(i, a, b) for (int i = a; i <= b; i++)
#define INT_SIZE 18
#define maxn 310
#define Maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

int a[maxn], dp[Maxn];

int main() {
  IOS;
  int n, k;
  cin >> n >> k;
  ForB(i, 1, n) cin >> a[i];
  ForB(i, 0, k) {
    ForB(j, 1, n) {
      if (i >= a[j] && !dp[i - a[j]]) {
        dp[i] = true;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << '\n';
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}