Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define FASTIO
#define endl                                                                   \
  "\n" // Since endl forces a buffer flush which slows down large I/O
       // operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)                                                            \
  for (int i = 0; i < (n); i++)                                                \
    cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)                                                                \
  for (auto i : (c))                                                           \
    cout << i << " ";                                                          \
  cout << "\n";
#define display(c, n)                                                          \
  for (int i = 0; i < (n); i++)                                                \
    cout << (c)[i] << " ";                                                     \
  cout << "\n";
#define forl(i, a, n) for (int(i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
 */

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b) {
  if (b == 0)
    return 1LL;

  ll res = mod_pow(a, b >> 1);
  res = (res * res) % mod;
  if (b & 1LL)
    res = (res * a) % mod;

  return res;
}

const int N = 100 + 5;
const int SZ = 1e5 + 5;

int n, k;
int a[N];
int dp[SZ][2];

int solve(int k, int plaiya) {
  if (k < 0)
    return 1;
  int win = 0;
  for (int i = 0; i < n; i++) {
    win |= !(solve(k - a[i], plaiya ^ 1));
  }
  return win;
}

int32_t main() {
#ifdef FASTIO
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif
  // freopen("in.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  memset(dp, -1, sizeof dp);

  cin >> n >> k;
  forl(i, 0, n) { cin >> a[i]; }

  int ans = solve(k, 0);

  cout << (ans ? "First" : "Second") << "\n";

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define FASTIO
#define endl                                                                   \
  "\n" // Since endl forces a buffer flush which slows down large I/O
       // operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n)                                                            \
  for (int i = 0; i < (n); i++)                                                \
    cin >> (c)[i];
#define exit_message(s) return 0 * printf(s)
#define show(c)                                                                \
  for (auto i : (c))                                                           \
    cout << i << " ";                                                          \
  cout << "\n";
#define display(c, n)                                                          \
  for (int i = 0; i < (n); i++)                                                \
    cout << (c)[i] << " ";                                                     \
  cout << "\n";
#define forl(i, a, n) for (int(i) = (a); (i) < (n); (i)++)
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
 */

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vill;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;

ll mod_pow(ll a, ll b) {
  if (b == 0)
    return 1LL;

  ll res = mod_pow(a, b >> 1);
  res = (res * res) % mod;
  if (b & 1LL)
    res = (res * a) % mod;

  return res;
}

const int N = 100 + 5;
const int SZ = 1e5 + 5;

int n, k;
int a[N];
int dp[SZ][2];

int solve(int k, int plaiya) {
  if (k < 0)
    return 1;

  int &win = dp[k][plaiya];
  if (win != -1)
    return win;

  win = 0;
  for (int i = 0; i < n; i++) {
    win |= !(solve(k - a[i], plaiya ^ 1));
  }
  return win;
}

int32_t main() {
#ifdef FASTIO
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif
  // freopen("in.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  memset(dp, -1, sizeof dp);

  cin >> n >> k;
  forl(i, 0, n) { cin >> a[i]; }

  int ans = solve(k, 0);

  cout << (ans ? "First" : "Second") << "\n";

  return 0;
}