prithivMLmods/Coder-Stat huggingface dataset:
Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
ll n, k;
vector<vector<ll>> dp(100010, vector<ll>(2, inf));
vector<ll> a(110);
ll solve(ll x, ll y) {
  if (dp[x][y] != inf)
    return dp[x][y];
  if (x < a[0])
    return 1 - y;
  ll res;
  if (y == 1)
    res = 0;
  else
    res = 1;
  rep(i, n) {
    if (x < a[i])
      continue;
    if (y == 1)
      if (solve(x - a[i], 0) == 1)
        res = 1;
    if (y == 0)
      if (solve(x - a[i], 1 - y) == 0)
        res = 0;
  }
  return res;
}
int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  if (solve(k, 0))
    cout << "Second" << endl;
  else
    cout << "First" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
ll n, k;
vector<vector<ll>> dp(100010, vector<ll>(2, inf));
vector<ll> a(110);
ll solve(ll x, ll y) {
  if (dp[x][y] != inf)
    return dp[x][y];
  if (x < a[0])
    return 1 - y;
  ll res;
  if (y == 1)
    res = 0;
  else
    res = 1;
  rep(i, n) {
    if (x < a[i])
      continue;
    if (y == 1)
      if (solve(x - a[i], 0) == 1)
        res = 1;
    if (y == 0)
      if (solve(x - a[i], 1 - y) == 0)
        res = 0;
  }
  dp[x][y] = res;
  return res;
}
int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  if (solve(k, 0))
    cout << "Second" << endl;
  else
    cout << "First" << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1e9 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<bool> dp(n + 1);
  for (int i = 0; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (i >= a[j] && !dp[i - a[j]])
        dp[i] = true;
    }
  }
  dp[k] ? (cout << "First") : (cout << "Second");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1e9 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<bool> dp(k + 1);
  for (int i = 0; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (i >= a[j] && !dp[i - a[j]])
        dp[i] = true;
    }
  }
  dp[k] ? (cout << "First") : (cout << "Second");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, a, b) for (ll i = a; i < b; ++i)
const ll MOD = 1000003;
const ll INF = 1e9;
const ll IINF = 1e18;
const double EPS = 1e-8;
const double pi = acos(-1);

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  vector<bool> decide(K + 1, false);
  rep(i, K + 1) {
    if (!decide[i]) {
      rep(j, N) decide[i + a[j]] = true;
    }
  }
  if (decide[K])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, a, b) for (ll i = a; i < b; ++i)
const ll MOD = 1000003;
const ll INF = 1e9;
const ll IINF = 1e18;
const double EPS = 1e-8;
const double pi = acos(-1);

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  vector<bool> decide(K + 1, false);
  rep(i, K + 1) {
    if (!decide[i]) {
      rep(j, N) {
        if (i + a[j] > K)
          continue;
        decide[i + a[j]] = true;
      }
    }
  }
  if (decide[K])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
// cin.tie(0);
// ios::sync_with_stdio(false);

int dp[100010] = {}; // 0==lose

signed main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  rep(i, k + 1) {
    rep(j, n) { dp[i + a[j]] = max(1 - dp[i], dp[i + a[j]]); }
  }

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
// cin.tie(0);
// ios::sync_with_stdio(false);

int dp[500010] = {}; // 0==lose

signed main() {
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  rep(i, k + 1) {
    rep(j, n) { dp[i + a[j]] = max(1 - dp[i], dp[i + a[j]]); }
  }

  if (dp[k] == 1) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}
Problem p03170 (C++)

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

const int MAX = 1e5 + 10;
int dp[MAX];
int main() {
  int N, K, i, j;
  cin >> N >> K;
  int a[N];
  int flag;
  for (i = 0; i < N; i++)
    cin >> a[i];
  for (i = 0; i < a[0]; i++)
    dp[i] = -1;
  for (i = a[0]; i < K + 1; i++) {
    flag = 0;
    for (j = 0; j < N; j++) {
      if (dp[i - a[j]] == -1) {
        flag++;
        break;
      }
    }
    if (flag > 0)
      dp[i] = 1;
    else {
      dp[i] = -1;
    }
  }
  if (dp[K] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

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

const int MAX = 1e5 + 10;
int dp[MAX];
int main() {
  int N, K, i, j;
  cin >> N >> K;
  int a[N];
  int flag;
  for (i = 0; i < N; i++)
    cin >> a[i];
  for (i = 0; i < a[0]; i++)
    dp[i] = -1;
  for (i = a[0]; i < K + 1; i++) {
    flag = 0;
    for (j = 0; j < N; j++) {
      if (i < a[j])
        break;
      else if (dp[i - a[j]] == -1) {
        flag++;
        break;
      }
    }
    if (flag > 0)
      dp[i] = 1;
    else {
      dp[i] = -1;
    }
  }
  if (dp[K] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template <typename T> using s = set<T>;
template <typename T> using v = vector<T>;
template <typename T1, typename T2> using p = pair<T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;

const int Max = 4e3 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, k;
bool dp[Max];
ll A[Max];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> A[i];
  // He Cant Do Any Move So Lose
  dp[0] = false;
  for (int i = 1; i <= k; i++) {
    bool foundLoose = false;
    for (var s : A) {
      if (s == 0)
        break;
      if (i >= s) {
        foundLoose = !dp[i - s];
      }
      if (foundLoose)
        break;
    }
    dp[i] = foundLoose;
  }

  if (dp[k])
    cout << "First";
  else
    cout << "Second";
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template <typename T> using s = set<T>;
template <typename T> using v = vector<T>;
template <typename T1, typename T2> using p = pair<T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;

const int Max = 1e5 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, k;
bool dp[Max];
ll A[Max];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> A[i];
  // He Cant Do Any Move So Lose
  dp[0] = false;
  for (int i = 1; i <= k; i++) {
    bool foundLoose = false;
    for (var s : A) {
      if (s == 0)
        break;
      if (i >= s) {
        foundLoose = !dp[i - s];
      }
      if (foundLoose)
        break;
    }
    dp[i] = foundLoose;
  }

  if (dp[k])
    cout << "First";
  else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)

bool dp[100010];

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

  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= K; i++) {
    if (dp[i])
      continue;
    rep(j, N) {
      int x = a[j];
      dp[i + x] = true;
    }
  }
  if (dp[K])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)

bool dp[100010];

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

  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= K; i++) {
    if (dp[i])
      continue;
    rep(j, N) {
      int x = a[j];
      if (i + x > K)
        continue;
      dp[i + x] = true;
    }
  }
  if (dp[K])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  bool dp[k + 1];
  memset(dp, 0, sizeof(dp));

  for (int i = 1; i <= k; i++) {
    for (int val : a) {
      if (val > i)
        continue;

      if (dp[i - val] == 0)
        dp[i] = 1;
    }
  }

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

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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  bool dp[k + 1];
  memset(dp, 0, sizeof(dp));

  for (int i = 1; i <= k; i++) {
    for (int val : a) {
      if (val > i)
        continue;

      if (dp[i - val] == 0)
        dp[i] = 1;
    }
  }

  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

VI memo;
int dfs(int k, VI &av) {
  if (memo[k] != 0)
    return memo[k];
  int first_res = -1;
  for (auto a1 : av) {
    if (k - a1 >= 0) {
      int second_res = 1;
      for (auto a2 : av) {
        if (k - a1 - a2 >= 0)
          second_res = min(second_res, dfs(k - a1 - a2, av));
      }
      first_res = max(first_res, second_res);
    }
  }
  return memo[k] = first_res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VI a(n);
  REP(i, n) cin >> a[i];
  memo.resize(k + 1);
  cout << (dfs(k, a) == 1 ? "First" : "Second") << ln;
  return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

VI memo;
int dfs(int k, VI &av) {
  if (memo[k] != 0)
    return memo[k];
  int first_res = -1;
  for (auto a1 : av) {
    if (k - a1 >= 0) {
      int second_res = 1;
      if (memo[k - a1] != 0) {
        second_res = memo[k - a1] * -1;
      } else {
        for (auto a2 : av)
          if (k - a1 - a2 >= 0)
            second_res = min(second_res, dfs(k - a1 - a2, av));
        memo[k - a1] = second_res * -1;
      }
      first_res = max(first_res, second_res);
    }
  }
  return memo[k] = first_res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  VI a(n);
  REP(i, n) cin >> a[i];
  memo.resize(k + 1);
  cout << (dfs(k, a) == 1 ? "First" : "Second") << ln;
  return 0;
}
Problem p03170 (C++)

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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> dp(n + 5);
  for (int stone = 0; stone <= k; stone++) {
    for (int x : a) // Foreach stones in array a
    {
      if (x <= stone && !dp[stone - x]) {
        dp[stone] = true;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << "\n";
  return 0;
}

/*
        dp[i]: True if player 1 win with i stones remaining
    The relation is: if (current x <= i remaining stones AND dp[remaining
   stones] = false) dp[i] = true Why dp[stone-x] needs to be false: because
   after stone - x the turn will change to the player 2 and if dp[stone-x] =
   false is mean that player 2 loose => player 1 win
 */

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> dp(k + 5);
  for (int stone = 0; stone <= k; stone++) {
    for (int x : a) // Foreach stones in array a
    {
      if (x <= stone && !dp[stone - x]) {
        dp[stone] = true;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << "\n";
  return 0;
}

/*
        dp[i]: True if player 1 win with i stones remaining
    The relation is: if (current x <= i remaining stones AND dp[remaining
   stones] = false) dp[i] = true Why dp[stone-x] needs to be false: because
   after stone - x the turn will change to the player 2 and if dp[stone-x] =
   false is mean that player 2 loose => player 1 win
 */
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define MOD 1000000007
#define M 105
#define N 100005
#define inf 1000000001
using namespace std;
ll n, k;
ll arr[M], dp[M]; // k

void solve() {
  // 0 means 2nd player and 1 means 1st player
  // if there is no element in the pile , 1st player will have nothing to take
  // and 2nd player will always win

  for (ll i = 0; i < k; i++) {    // height of pile
    for (ll j = 1; j <= n; j++) { // no of element
      if (i + arr[j] <= k && !dp[i]) {
        dp[i + arr[j]] = 1;
      }
    } // cout<< endl;
  }
  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";
  // cout<< setprecision(10)<< ans<< endl;
}

int main() {
  // ll t; cin>> t; while(t--){
  cin >> n >> k;
  for (ll i = 1; i <= n; i++) { // no of item
    cin >> arr[i];
  }
  solve();
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define MOD 1000000007
#define M 105
#define N 100005
#define inf 1000000001
using namespace std;
ll n, k;
ll arr[M], dp[N]; // k

void solve() {
  // 0 means 2nd player and 1 means 1st player
  // if there is no element in the pile , 1st player will have nothing to take
  // and 2nd player will always win

  for (ll i = 0; i < k; i++) {    // height of pile
    for (ll j = 1; j <= n; j++) { // no of element
      if (i + arr[j] <= k && !dp[i]) {
        dp[i + arr[j]] = 1;
      }
    } // cout<< endl;
  }
  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";
  // cout<< setprecision(10)<< ans<< endl;
}

int main() {
  // ll t; cin>> t; while(t--){
  cin >> n >> k;
  for (ll i = 1; i <= n; i++) { // no of item
    cin >> arr[i];
  }
  solve();
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define FASTIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const int maxN = 1e2 + 5;
const int maxK = 1e5 + 5;
const int mod = 1e9 + 7;
int arr[maxN];
bool dp[maxN];
int n, k;

void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i < k + 1; i++) {
    for (int j = 0; j < n; j++) {
      if (i - arr[j] >= 0) {
        if (dp[i - arr[j]] == false) {
          dp[i] = true;
          break;
        }
      } else {
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

int main() {
  FASTIO
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define FASTIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;
int arr[maxN];
bool dp[maxN];
int n, k;

void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i < k + 1; i++) {
    for (int j = 0; j < n; j++) {
      if (i - arr[j] >= 0) {
        if (dp[i - arr[j]] == false) {
          dp[i] = true;
          break;
        }
      } else {
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

int main() {
  FASTIO
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int n, k, temp;
int dp[10002];
void solve() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    arr.push_back(temp);
  }

  dp[0] = 0;

  for (int i = 1; i <= k; i++) {
    dp[i] = 0;
    for (auto moves : arr) {
      if ((i - moves) >= 0) {
        if (dp[i - moves] == 0)
          dp[i] = 1;
      }
    }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
int main(void) { solve(); }

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int n, k, temp;
int dp[100002];
void solve() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    arr.push_back(temp);
  }

  dp[0] = 0;

  for (int i = 1; i <= k; i++) {
    dp[i] = 0;
    for (auto moves : arr) {
      if ((i - moves) >= 0) {
        if (dp[i - moves] == 0)
          dp[i] = 1;
      }
    }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
int main(void) { solve(); }
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(a, n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Graph;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1e18;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<bool> dp(n, false);
  for (int i = 1; i <= k; i++) {
    rep(j, n) {
      if (i - a[j] < 0)
        continue;
      if (!dp[i - a[j]]) {
        dp[i] = true;
      }
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(a, n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Graph;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1e18;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<bool> dp(k + 1, false);
  for (int i = 1; i <= k; i++) {
    rep(j, n) {
      if (i - a[j] < 0)
        continue;
      if (!dp[i - a[j]]) {
        dp[i] = true;
      }
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int n, k;
int a[110];
bool vis[100100][2];
bool dp[100100][2];
bool check(int x, int p) {
  if (x < 0)
    return true;
  if (vis[x][p])
    return dp[x][p];
  for (int i = 0; i < n; i++) {
    if (!check(x - a[i], !p))
      dp[x][p] = true;
  }
  return dp[x][p];
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (check(k, 0)) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int n, k;
int a[110];
bool vis[100100][2];
bool dp[100100][2];
bool check(int x, int p) {
  if (x < 0)
    return true;
  if (vis[x][p])
    return dp[x][p];
  vis[x][p] = true;
  for (int i = 0; i < n; i++) {
    if (!check(x - a[i], !p))
      dp[x][p] = true;
  }
  return dp[x][p];
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (check(k, 0)) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}
Problem p03170 (C++)

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

// dp[i] - 1 if first player can win with i stones, 0 otherwise
int N, K, a[105];
bool dp[10005];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= K; i++) {
    bool find = false;
    for (int j = 0; j < N; j++) {
      if (i - a[j] < 0)
        continue;
      if (dp[i - a[j]] == 0) {
        find = true;
      }
    }
    if (find) {
      dp[i] = 1;
    } else {
      dp[i] = 0;
    }
  }
  if (dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

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

// dp[i] - 1 if first player can win with i stones, 0 otherwise
int N, K, a[105];
bool dp[100005];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  for (int i = 1; i <= K; i++) {
    bool find = false;
    for (int j = 0; j < N; j++) {
      if (i - a[j] < 0)
        continue;
      if (dp[i - a[j]] == 0) {
        find = true;
      }
    }
    if (find) {
      dp[i] = 1;
    } else {
      dp[i] = 0;
    }
  }
  if (dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);

li n, k, a[107], dp[100007];

int main() {
  fastIO;
  cin >> n >> k;
  for (li i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  for (li i = 0; i <= a[0]; i++)
    dp[i] = 1;
  for (li i = 0; i <= k; i++) {
    if (!dp[i])
      dp[i] = 1;

    if (dp[i] == 1)
      for (li j = 0; j < n; j++) {
        dp[i + a[j]] = 2;
      }
  }

  if (dp[k] == 2)
    cout << "First";
  else
    cout << "Second";
}


Fixed submission:
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO                                                                 \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);

li n, k, a[107], dp[100007];

int main() {
  fastIO;
  cin >> n >> k;
  for (li i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  for (li i = 0; i <= a[0]; i++)
    dp[i] = 1;
  for (li i = 0; i <= k; i++) {
    if (!dp[i])
      dp[i] = 1;

    if (dp[i] == 1)
      for (li j = 0; j < n; j++) {
        if (i + a[j] > k)
          continue;
        dp[i + a[j]] = 2;
      }
  }

  if (dp[k] == 2)
    cout << "First";
  else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, K;
int DP[100010] = {};
int main() {
  cin >> N >> K;
  int a[N];
  REP(i, N) { cin >> a[i]; }
  REP(i, K) {
    REP(j, N) {
      if (DP[i] == 0) {
        chmax(DP[i + a[j]], 1);
      }
    }
  }
  string res;
  if (DP[K] == 0) {
    res = "Second";
  } else {
    res = "First";
  }
  cout << res;
}


Fixed submission:
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, K;
int DP[100010] = {};
int main() {
  cin >> N >> K;
  int a[N];
  REP(i, N) { cin >> a[i]; }
  REP(i, K) {
    REP(j, N) {
      if (DP[i] == 0) {
        if (i + a[j] <= K)
          chmax(DP[i + a[j]], 1);
      }
    }
  }
  string res;
  if (DP[K] == 0) {
    res = "Second";
  } else {
    res = "First";
  }
  cout << res;
}
Problem p03170 (C++)

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

using namespace std;

int main() {

  ios::sync_with_stdio(0);

  int n, k;

  cin >> n >> k;

  vector<int> dp(k + 1, 0), arr(n);

  for (int i = 0; i < n; i += 1) {

    cin >> arr[i];
  }

  for (int i = 0; i <= k; i += 1) {

    if (dp[i] == 0) {

      for (int j = 0; j < n; j += 1) {

        dp[i + arr[j]] = 1;
      }
    }
  }

  if (dp[k]) {

    cout << "First";
  }

  else {

    cout << "Second";
  }
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {

  ios::sync_with_stdio(0);

  int n, k;

  cin >> n >> k;

  vector<int> dp(k + 1, 0), arr(n);

  for (int i = 0; i < n; i += 1) {

    cin >> arr[i];
  }

  for (int i = 0; i <= k; i += 1) {

    if (dp[i] == 0) {

      for (int j = 0; j < n; j += 1) {

        if (i + arr[j] <= k) {

          dp[i + arr[j]] = 1;
        }
      }
    }
  }

  if (dp[k]) {

    cout << "First";
  }

  else {

    cout << "Second";
  }
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

typedef long long ll;

const ll mod = 1e9 + 7;

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define rc(x) return cout << x << "\n", 0
#define sz(s) (int)s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

ll n, x, k;
bool dp[10005];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  ll a[k + 2];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int stones = 0; stones <= k; stones++) {
    for (int x = 1; x <= n; x++) {
      if (stones >= a[x] && dp[stones - a[x]] == 0) {
        dp[stones] = true;
        break;
      }
    }
  }
  if (dp[k] == true) {
    cout << "First";
  } else
    cout << "Second";
}


Fixed submission:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

typedef long long ll;

const ll mod = 1e9 + 7;

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define rc(x) return cout << x << "\n", 0
#define sz(s) (int)s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

ll n, x, k;
bool dp[100005];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  ll a[k + 2];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int stones = 0; stones <= k; stones++) {
    for (int x = 1; x <= n; x++) {
      if (stones >= a[x] && dp[stones - a[x]] == 0) {
        dp[stones] = true;
        break;
      }
    }
  }
  if (dp[k] == true) {
    cout << "First";
  } else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int, int> p2;
typedef pair<p2, int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5 + 100;

int N, K, a[MAX], dp[MAX];

int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++)
    cin >> a[i];
  for (int i = 1; i <= K; i++) {
    for (int j = 1; i - a[j] >= 0 && j <= N; j++)
      if (dp[i - a[j]] == 0) {
        dp[i] = 1;
        break;
      }
  }
  cout << (dp[K] ? "First" : "Second") << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int, int> p2;
typedef pair<p2, int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5 + 100;

int N, K, a[MAX], dp[100005];

int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++)
    cin >> a[i];
  for (int i = 1; i <= K; i++) {
    for (int j = 1; i - a[j] >= 0 && j <= N; j++)
      if (dp[i - a[j]] == 0) {
        dp[i] = 1;
        break;
      }
  }
  cout << (dp[K] ? "First" : "Second") << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[100005] = {};
int main() {
  std::ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<ll> v;
  for (int i = 0; i < n; i++) {
    ll num;
    cin >> num;
    v.push_back(num);
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < v.size(); j++) {
      if (dp[i - v[j]] == 0 && i - v[j] >= 0)
        dp[i] = 1;
    }
  }
  // cout<<dp[k]<<endl;
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll dp[100005] = {};
int main() {
  std::ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<ll> v;
  for (int i = 0; i < n; i++) {
    ll num;
    cin >> num;
    v.push_back(num);
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < v.size(); j++) {
      if (i - v[j] >= 0) {
        if (dp[i - v[j]] == 0)
          dp[i] = 1;
      }
    }
  }
  // cout<<dp[k]<<endl;
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

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

int n, k; // how many stones are left
bool dp[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (dp[i - a[j]] == false && i - a[j] >= 0) {
        dp[i] = true;
      }
    }
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}

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

int n, k; // how many stones are left
bool dp[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (i - a[j] >= 0 && dp[i - a[j]] == false) {
        dp[i] = true;
      }
    }
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define boost_io                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define debug(x) cout << #x << ":" << x << " "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF = 1e9 + 7;
ll INF = 1e11;

void solve() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi dp(k + 1);
  for (int i = 0; i <= k; i++) {
    if (i == 0) {
      dp[i] = 2;
    } else {
      int pos = 0;
      for (int j = 0; j < n && a[j] <= k; j++) {
        if (dp[i - a[j]] == 2) {
          pos = 1;
          break;
        }
      }
      if (pos) {
        dp[i] = 1;
      } else {
        dp[i] = 2;
      }
    }
  }
  if (dp[k] == 1) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
}

int main() {
  boost_io;
  cout << setprecision(10);
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define boost_io                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define debug(x) cout << #x << ":" << x << " "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF = 1e9 + 7;
ll INF = 1e11;

void solve() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi dp(k + 1);
  for (int i = 0; i <= k; i++) {
    if (i == 0) {
      dp[i] = 2;
    } else {
      int pos = 0;
      for (int j = 0; j < n && a[j] <= i; j++) {
        if (dp[i - a[j]] == 2) {
          pos = 1;
          break;
        }
      }
      if (pos) {
        dp[i] = 1;
      } else {
        dp[i] = 2;
      }
    }
  }
  if (dp[k] == 1) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
}

int main() {
  boost_io;
  cout << setprecision(10);
  solve();
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
//-----by LY02------------------------------------
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define M 1000000007
//------------------------------------------------

int st[110];
int dp[100010];

//------------------------------------------------
int main() {
  //------------------------------------------------
  //	freopen("In.txt","r",stdin);
  //	freopen("Out.txt","w",stdout);
  //------------------------------------------------
  ios::sync_with_stdio(0);
  cin.tie(0);
  //------------------------------------------------

  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> st[i];

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (j + st[j] > k)
        continue;
      if (dp[i] == 0)
        dp[i + st[j]] = 1;
    }
  }

  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";
  //------------------------------------------------
  return 0;
}

//-----by LY02------------------------------------


Fixed submission:
//-----by LY02------------------------------------
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define M 1000000007
//------------------------------------------------

int st[110];
int dp[100010];

//------------------------------------------------
int main() {
  //------------------------------------------------
  //	freopen("In.txt","r",stdin);
  //	freopen("Out.txt","w",stdout);
  //------------------------------------------------
  ios::sync_with_stdio(0);
  cin.tie(0);
  //------------------------------------------------

  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> st[i];

  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (i + st[j] > k)
        continue;
      if (dp[i] == 0)
        dp[i + st[j]] = 1;
    }
  }

  if (dp[k])
    cout << "First\n";
  else
    cout << "Second\n";
  //------------------------------------------------
  return 0;
}

//-----by LY02------------------------------------
Problem p03170 (C++)

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pt;
typedef pair<ll, ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i, n) for (int i = 0; i < n; i++)
#define Fr(i, l, r) for (int i = l; i <= r; i++)
#define rF(i, n) for (int i = n - 1; i >= 0; i--)
#define all(arr) arr.begin(), arr.end()

ll Lpow(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b % 2)
      ans = (ans * a);
    a = (a * a);
    b = b / 2;
  }
  return ans;
}

ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

signed main() {
  fastio;
  //    cout.flush();

  int n, k;
  cin >> n >> k;

  vector<int> arr(n);
  int mi = intinf;
  F(i, n) {
    cin >> arr[i];
    mi = min(mi, arr[i]);
  }

  sort(all(arr));

  vector<int> brr(100005, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < mi; j++) {
      brr[arr[i] + j] = 1;
    }
  }

  for (int i = 1; i <= 100000; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[j] < i && brr[i - arr[j]] == 0)
        brr[i] = 1;
    }
  }

  if (brr[k] == 1)
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pt;
typedef pair<ll, ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i, n) for (int i = 0; i < n; i++)
#define Fr(i, l, r) for (int i = l; i <= r; i++)
#define rF(i, n) for (int i = n - 1; i >= 0; i--)
#define all(arr) arr.begin(), arr.end()

ll Lpow(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b % 2)
      ans = (ans * a);
    a = (a * a);
    b = b / 2;
  }
  return ans;
}

ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

signed main() {
  fastio;
  //    cout.flush();

  int n, k;
  cin >> n >> k;

  vector<int> arr(n);
  int mi = intinf;
  F(i, n) {
    cin >> arr[i];
    mi = min(mi, arr[i]);
  }

  sort(all(arr));

  vector<int> brr(100005, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < mi; j++) {
      if (arr[i] + j <= 100000)
        brr[arr[i] + j] = 1;
    }
  }

  for (int i = 1; i <= 100000; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[j] < i && brr[i - arr[j]] == 0)
        brr[i] = 1;
    }
  }

  if (brr[k] == 1)
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}
Problem p03170 (C++)

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

using namespace std;

#define ops cout << "ops" << endl;
#define freopens                                                               \
  freopen("cowpatibility.in", "r", stdin);                                     \
  freopen("cowpatibility.out", "w", stdout);
#define fast                                                                   \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);

#define DIM 100007
#define DIMM 107
#define INF 1000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr = (1 + sqrt(5)) / 2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I, I> pII;
typedef pair<ll, ll> pllll;
typedef pair<ld, ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n, k;
ll ma;
ll a[DIMM], dp[DIM];

int main() {
  // ops;
  // freopens;
  fast;
  // ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (dp[i - a[j]] == 0) {
        dp[i] = 1;
        break;
      }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define ops cout << "ops" << endl;
#define freopens                                                               \
  freopen("cowpatibility.in", "r", stdin);                                     \
  freopen("cowpatibility.out", "w", stdout);
#define fast                                                                   \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);

#define DIM 100007
#define DIMM 107
#define INF 1000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr = (1 + sqrt(5)) / 2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I, I> pII;
typedef pair<ll, ll> pllll;
typedef pair<ld, ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n, k;
ll ma;
ll a[DIMM], dp[DIM];

int main() {
  // ops;
  // freopens;
  fast;
  // ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];

  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (i >= a[j] && dp[i - a[j]] == 0) {
        dp[i] = 1;
        break;
      }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}