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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
vecint a;
vec2int dp;
int n, k;
bool rec(int p, int q) {
  // if (p <= 0) return false;
  if (dp[p][q] != -1)
    return dp[p][q] == 1 ? true : false;
  int r = 0;
  if (q == 0)
    r = 1;
  REP(i, n) {
    if (p <= a[i]) {
      if (!rec(p - a[i], r)) {
        dp[p][q] = 1;
        return true;
      }
    }
  }
  dp[p][q] = 0;
  return false;
}
int main() {
  init();
  cin >> n >> k;
  a.resize(n);
  for (auto &e : a)
    cin >> e;
  dp = vector<vector<int>>(k + 1, vecint(2, -1));
  // REP(i, a[0]) dp[i][0] = dp[i][1] = 0;
  // for (const auto& e : a) dp[e][0] = dp[e][1] = 1;
  // // REP(i, k + 1) { cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
  // }
  cout << (rec(k, 0) ? "First" : "Second") << endl;
  // REP(i, k + 1) { cout << "i: " << dp[i][0] << " " << dp[i][1] << endl; }
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
vecint a;
vec2int dp;
int n, k;
bool rec(int p, int q) {
  // if (p <= 0) return false;
  if (dp[p][q] != -1)
    return dp[p][q] == 1 ? true : false;
  int r = 0;
  if (q == 0)
    r = 1;
  REP(i, n) {
    if (p >= a[i]) {
      if (!rec(p - a[i], r)) {
        dp[p][q] = 1;
        return true;
      }
    }
  }
  dp[p][q] = 0;
  return false;
}
int main() {
  init();
  cin >> n >> k;
  a.resize(n);
  for (auto &e : a)
    cin >> e;
  dp = vector<vector<int>>(k + 1, vecint(2, -1));
  // REP(i, a[0]) dp[i][0] = dp[i][1] = 0;
  // for (const auto& e : a) dp[e][0] = dp[e][1] = 1;
  // // REP(i, k + 1) { cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
  // }
  cout << (rec(k, 0) ? "First" : "Second") << endl;
  // REP(i, k + 1) { cout << "i: " << dp[i][0] << " " << dp[i][1] << endl; }
}
Problem p03170 (C++)

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

#include <iostream>
// #include <algorithm>
//  #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[110000];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }

  for (ll i = 0; i <= K; i++) {
    if (!dp[i]) {
      for (ll j = 0; j < N; j++) {
        dp[i + list[j]] = 1;
      }
    }
  }

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


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

#include <iostream>
// #include <algorithm>
//  #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[110000];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }

  for (ll i = 0; i <= K; i++) {
    if (!dp[i]) {
      for (ll j = 0; j < N; j++) {
        if (i + list[j] <= K) {
          dp[i + list[j]] = 1;
        }
      }
    }
  }

  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 n, arr[101], k;
bool dp[100001];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (!dp[i - arr[j]]) {
        dp[i] = true;
        break;
      }
    }
  }
  if (dp[k]) {
    cout << "First" << '\n';
  } else {
    cout << "Second" << '\n';
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, arr[101], k;
bool dp[100001];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (arr[j] > i) {
        break;
      }
      if (!dp[i - arr[j]]) {
        dp[i] = true;
        break;
      }
    }
  }
  if (dp[k]) {
    cout << "First" << '\n';
  } else {
    cout << "Second" << '\n';
  }
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
/*
 *  author: chw0501
 *  created: 15.04.2020 07:37:31(UTC)
 */
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n, k;
vector<int> v;
// dp[i]: i개의 돌이 남았을 때 플레이 할 때 이번 플레이어가 이기면 1, 지면 0을
// 저장
int dp[100001];

int solve(int i) {
  int &ret = dp[i];
  if (ret != -1)
    return ret;
  if (i < v[0])
    return ret = 0;
  ret = 0;
  for (int j = 0; j < n; j++) {
    if (solve(i - v[j]) == 0)
      ret = 1;
  }
  return ret;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  memset(dp, -1, sizeof(dp));
  if (solve(k) == 1)
    cout << "First";
  else
    cout << "Second";
  return 0;
}

Fixed submission:
/*
 *  author: chw0501
 *  created: 15.04.2020 07:37:31(UTC)
 */
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int n, k;
vector<int> v;
// dp[i]: i개의 돌이 남았을 때 플레이 할 때 이번 플레이어가 이기면 1, 지면 0을
// 저장
int dp[100001];

int solve(int i) {
  int &ret = dp[i];
  if (ret != -1)
    return ret;
  if (i < v[0])
    return ret = 0;
  ret = 0;
  for (int j = 0; j < n; j++) {
    if (v[j] > i)
      break;
    if (solve(i - v[j]) == 0)
      ret = 1;
  }
  return ret;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  memset(dp, -1, sizeof(dp));
  if (solve(k) == 1)
    cout << "First";
  else
    cout << "Second";
  return 0;
}
Problem p03170 (C++)

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

using namespace std;

int n, k, a[105], dp[100005];

int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

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

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

  cout << (dp[k] ? "First\n" : "Second\n");

  return 0;
}


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

using namespace std;

int n, k, a[100005], dp[200005];

int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);

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

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

  cout << (dp[k] ? "First\n" : "Second\n");

  return 0;
}
Problem p03170 (C++)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }

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


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }

  vector<bool> dp(k + 1);
  dp[0] = false;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (dp[i] == false && i + a[j] <= k) {
        dp[i + a[j]] = true;
      }
    }
  }
  if (dp[k] == true) {
    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, a[101];
bool dp[100001];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0] = false;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (dp[i - a[j]] == false && i >= a[j]) {
        dp[i] = true;
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First";
  else
    cout << "Second";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, k, a[101];
bool dp[100001];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0] = false;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (i >= a[j] && dp[i - a[j]] == false) {
        dp[i] = true;
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First";
  else
    cout << "Second";
}
Problem p03170 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

bool dp[100100];

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

  rep(i, k) rep(j, n) if (!dp[i]) dp[i + a[j]] = true;

  cout << (dp[k] ? "First" : "Second") << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

bool dp[200100];

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

  rep(i, k) rep(j, n) if (!dp[i]) dp[i + a[j]] = true;

  cout << (dp[k] ? "First" : "Second") << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#define MAXK 100100
using namespace std;

int dp[MAXK];
int A[110];

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

  for (int i = 0; i < n; i++)
    cin >> A[i];

  dp[0] = 1;

  for (int i = 0; i < n; i++) {
    dp[A[i]] = 0;
  }

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

Fixed submission:
#include <iostream>
#define MAXK 100100
using namespace std;

int dp[MAXK];
int A[110];

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

  for (int i = 0; i < n; i++)
    cin >> A[i];

  dp[0] = 1;

  for (int i = 0; i < n; i++) {
    dp[A[i]] = 0;
  }

  for (int i = 1; i <= k; i++) {
    if (dp[i] == -1) {
      dp[i] = 1;
      for (int j = 0; j < n; j++) {
        if (i + A[j] <= k) {
          dp[i + A[j]] = 0;
        }
      }
    }
  }
  if (dp[k] == 1) {
    cout << "Second\n";
  } else
    cout << "First\n";
}
Problem p03170 (C++)

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

int n, k;
int dp[100005];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = a[0]; i <= k; i++) {
    for (int j = 0; a[j] <= i; j++) {
      if (dp[i - a[j]] == 0)
        dp[i] = 1;
    }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}

Fixed submission:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int n, k;
int dp[100005];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = a[0]; i <= k; i++) {
    for (int j = 0; a[j] <= i && j < n; j++) {
      if (dp[i - a[j]] == 0)
        dp[i] = 1;
    }
  }
  if (dp[k] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast;

  ll n, k;
  cin >> n >> k;

  ll a[n];
  for (ll i = 0; i < n; i++)
    cin >> a[i];

  sort(a, a + n);

  bool dp[k + 1][2];
  // 0 odd 1 even
  for (ll i = 0; i < k + 1; i++)
    for (ll j = 0; j < 2; j++)
      dp[i][j] = 0;

  dp[0][1] = 1;

  for (ll i = 1; i <= k; i++) {
    bool f = 0, f1 = 0, t1 = 0, t2 = 0;
    for (ll j = 0; a[j] <= i; j++) {
      if (dp[i - a[j]][0] == 0 and dp[i - a[j]][1] == 1)
        dp[i][0] = 1;

      else if (dp[i - a[j]][0] == 1 and dp[i - a[j]][1] == 0)
        dp[i][1] = 1;
    }

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

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


Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main() {
  fast;

  ll n, k;
  cin >> n >> k;

  ll a[n];
  for (ll i = 0; i < n; i++)
    cin >> a[i];

  sort(a, a + n);

  bool dp[k + 1][2];
  // 0 odd 1 even
  for (ll i = 0; i < k + 1; i++)
    for (ll j = 0; j < 2; j++)
      dp[i][j] = 0;

  dp[0][1] = 1;

  for (ll i = 1; i <= k; i++) {
    bool f = 0, f1 = 0, t1 = 0, t2 = 0;
    for (ll j = 0; a[j] <= i; j++) {
      if (dp[i - a[j]][0] == 0 and dp[i - a[j]][1] == 1)
        dp[i][0] = 1;

      else if (dp[i - a[j]][0] == 1 and dp[i - a[j]][1] == 0)
        dp[i][1] = 1;
    }

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

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

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int dp[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int ar[n];
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    dp[ar[i]] = 1;
    mx = max(mx, ar[i]);
  }
  for (int i = 1; i <= k; i++) {
    if (dp[i] == 1)
      continue;
    for (int j = 1; j < n; j++) {
      if (dp[i - ar[j]] == 0) {
        dp[i] = 1;
      }
    }
  }
  if (dp[k] == 1)
    cout << "First";
  else
    cout << "Second";
}


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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int dp[100000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int ar[n];
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    dp[ar[i]] = 1;
    mx = max(mx, ar[i]);
  }
  for (int i = 1; i <= k; i++) {
    if (dp[i] == 1)
      continue;
    for (int j = 0; j < n; j++) {
      if (i - ar[j] >= 1 && dp[i - ar[j]] == 0) {
        dp[i] = 1;
      }
    }
  }
  if (dp[k] == 1)
    cout << "First";
  else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

char game(int K, vector<int> &a, vector<int> &in_set, vector<char> &state) {
  if (state[K] != 'X')
    return state[K];
  if (in_set[K]) {
    state[K] = 'W';
    return 'W';
  }
  char curr_state = 'L';
  for (int i = 0; i < a.size(); i++) {
    if (game(K - a[i], a, in_set, state) == 'L') {
      curr_state = 'W';
      break;
    }
  }
  state[K] = curr_state;
  return curr_state;
}

int32_t main() {
  fast_io;

  // int t; cin >> t;
  // while (t--) {

  // }
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> in_set(k + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    in_set[a[i]]++;
  }
  vector<char> state(k + 1, 'X');
  state[0] = 'L';
  char ans = game(k, a, in_set, state);
  if (ans == 'W') {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io                                                                \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

char game(int K, vector<int> &a, vector<int> &in_set, vector<char> &state) {
  if (state[K] != 'X')
    return state[K];
  if (in_set[K]) {
    state[K] = 'W';
    return 'W';
  }
  char curr_state = 'L';
  for (int i = 0; i < a.size(); i++) {
    if (K - a[i] >= 0 && game(K - a[i], a, in_set, state) == 'L') {
      curr_state = 'W';
      break;
    }
  }
  state[K] = curr_state;
  return curr_state;
}

int32_t main() {
  fast_io;

  // int t; cin >> t;
  // while (t--) {

  // }
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> in_set(k + 1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    in_set[a[i]]++;
  }
  vector<char> state(k + 1, 'X');
  state[0] = 'L';
  char ans = game(k, a, in_set, state);
  if (ans == 'W') {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T> void pr(T x) { cout << x << endl; }
template <class T> void prvec(vector<T> &a) {
  rep(i, a.size() - 1) { cout << a[i] << " "; }
  cout << a[a.size() - 1] << endl;
}
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 main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int dp[10010] = {};
  // rep(i, n) printf("%d ", a[i]); cout << endl;
  int m = 100000;
  rep(i, n) chmin(m, a[i]);
  rep(i, m) dp[i] = -1;
  for (int i : a)
    dp[i] = 1;

  rep(i, k + 1) {
    if (dp[i] != 0)
      continue;
    for (int j : a) {
      if (i - j >= 0 && dp[i - j] == -1) {
        dp[i] = 1;
        break;
      }
    }
    if (dp[i] == 0)
      dp[i] = -1;
  }

  // rep(i, k+1) printf("%d ", dp[i]); cout << endl;

  if (dp[k] == 1)
    printf("First\n");
  else
    printf("Second\n");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T> void pr(T x) { cout << x << endl; }
template <class T> void prvec(vector<T> &a) {
  rep(i, a.size() - 1) { cout << a[i] << " "; }
  cout << a[a.size() - 1] << endl;
}
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 main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int dp[100100] = {};
  // rep(i, n) printf("%d ", a[i]); cout << endl;
  int m = 100000;
  rep(i, n) chmin(m, a[i]);
  rep(i, m) dp[i] = -1;
  for (int i : a)
    dp[i] = 1;

  rep(i, k + 1) {
    if (dp[i] != 0)
      continue;
    for (int j : a) {
      if (i - j >= 0 && dp[i - j] == -1) {
        dp[i] = 1;
        break;
      }
    }
    if (dp[i] == 0)
      dp[i] = -1;
  }

  // rep(i, k+1) printf("%d ", dp[i]); cout << endl;

  if (dp[k] == 1)
    printf("First\n");
  else
    printf("Second\n");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 101;
const int V = 100010;

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

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++) {
    dp[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i - a[j] >= 0 && !dp[i - a[j]]) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
  return 0;
}


Fixed submission:
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 101;
const int V = 100010;

int n, k;
int a[N];
int dp[V];

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++) {
    dp[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i - a[j] >= 0 && !dp[i - a[j]]) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

// 最大公約数
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll x, ll y) {
  if (x == 0 || y == 0)
    return 0;
  return (x / gcd(x, y) * y);
}

bool dp[101010];
ll dx[4] = {0, 0, -1, 1};
ll dy[4] = {-1, 1, 0, 0};
ll a[303];

// long longしか使わない
// 素数は1より大きい
int main() {
  ll n, k;
  cin >> n >> k;
  rep(i, n) { cin >> a[i]; }
  for (ll i = 0; i <= k; ++i) {
    rep(j, n) {
      if (dp[i] == false) {
        dp[i + a[j]] = true;
      }
    }
  }
  if (dp[k])
    puts("First");
  else {
    puts("Second");
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

// 最大公約数
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll x, ll y) {
  if (x == 0 || y == 0)
    return 0;
  return (x / gcd(x, y) * y);
}

bool dp[1010101];
ll dx[4] = {0, 0, -1, 1};
ll dy[4] = {-1, 1, 0, 0};
ll a[303];

// long longしか使わない
// 素数は1より大きい
int main() {
  ll n, k;
  cin >> n >> k;
  rep(i, n) { cin >> a[i]; }
  for (ll i = 0; i <= k; ++i) {
    rep(j, n) {
      if (dp[i] == false) {
        dp[i + a[j]] = true;
      }
    }
  }
  if (dp[k])
    puts("First");
  else {
    puts("Second");
  }
  return 0;
}
Problem p03170 (C++)

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

#define ll long long
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
const int MOD = 1000000007;
bool DP[100001];
int main() {
  IOS;
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    DP[a[i]] = true;
  }
  for (int i = a[0] + 1; i <= K; i++) {
    if (DP[i])
      continue;
    for (int j = 0; j < N; j++) {
      if (!DP[i - a[j]]) {
        DP[i] = true;
        break;
      }
    }
  }
  if (DP[K])
    cout << "First";
  else
    cout << "Second";
  return 0;
}

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

#define ll long long
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
const int MOD = 1000000007;
bool DP[100001];
int main() {
  IOS;
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    DP[a[i]] = true;
  }
  for (int i = a[0] + 1; i <= K; i++) {
    if (DP[i])
      continue;
    for (int j = 0; j < N; j++) {
      if (i - a[j] >= 0 && !DP[i - a[j]]) {
        DP[i] = true;
        break;
      }
    }
  }
  if (DP[K])
    cout << "First";
  else
    cout << "Second";
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  vector<bool> dp(K + 1, false);
  rep(i, K + 1) {
    if (dp[i])
      continue;
    rep(j, N) {
      if (i + A.at(j) <= K)
        dp[i + A.at(j)] = 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;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;

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

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

using namespace std;

int n, k;
vector<int> v;
int dp[100005];

void solve() {
  for (int i = 1; i <= k; ++i) {
    if (dp[i] >= 0)
      continue;

    int res;
    for (int j = 0; j < n; ++j) {
      res = dp[i - v[j]];
      if (res == 1) {
        dp[i] = 2;
      } else if (res == 2) {
        dp[i] = 1;
        break;
      }
    }
  }
}

int main() {

  cin >> n >> k;

  memset(dp, -1, sizeof(dp));

  int num1, menor = 1000002;
  for (int i = 0; i < n; ++i) {
    cin >> num1;
    v.push_back(num1);
    dp[num1] = 1;
    menor = min(menor, num1);
  }

  for (int i = 0; i < menor; ++i) {
    dp[i] = 2;
  }

  solve();

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

  return 0;
}

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

using namespace std;

int n, k;
vector<int> v;
int dp[100005];

void solve() {
  for (int i = 1; i <= k; ++i) {
    if (dp[i] >= 0)
      continue;

    int res;
    for (int j = 0; j < n; ++j) {
      int tam = (i - v[j]);
      if (tam < 0)
        continue;
      res = dp[tam];
      if (res == 1) {
        dp[i] = 2;
      } else if (res == 2) {
        dp[i] = 1;
        break;
      }
    }
  }
}

int main() {

  cin >> n >> k;

  memset(dp, -1, sizeof(dp));

  int num1, menor = 1000002;
  for (int i = 0; i < n; ++i) {
    cin >> num1;
    v.push_back(num1);
    dp[num1] = 1;
    menor = min(menor, num1);
  }

  for (int i = 0; i < menor; ++i) {
    dp[i] = 2;
  }

  solve();

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

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 105, K = 100005;
int a[N], dp[K];
vector<int> q;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 0; i < a[1]; i++)
    dp[i] = 0;
  for (int i = a[1]; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (!dp[i - a[j]])
        dp[i] = 1;
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 105, K = 100005;
int a[N], dp[K];
vector<int> q;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 0; i < a[1]; i++)
    dp[i] = 0;
  for (int i = a[1]; i <= k; i++) {
    for (int j = 1; j <= n; j++)
      if (i >= a[j] && !dp[i - a[j]])
        dp[i] = 1;
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

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

  int df[K + 1];
  df[0] = 2;
  for (int i = 1; i < K + 1; i++) {
    bool t = false;
    for (int j = 0; j < n; j++) {
      if (df[i - niz[j]] == 2) {
        t = true;
        break;
      }
    }
    if (t == true)
      df[i] = 1;
    else
      df[i] = 2;
  }

  // for(int i=0; i<K+1; i++) cout<<df[i]<<" ";
  if (df[K] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

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

  int df[K + 1];
  df[0] = 2;
  for (int i = 1; i < K + 1; i++) {
    bool t = false;
    for (int j = 0; j < n; j++) {
      if (i >= niz[j] && df[i - niz[j]] == 2) {
        t = true;
        break;
      }
    }
    if (t == true)
      df[i] = 1;
    else
      df[i] = 2;
  }

  // for(int i=0; i<K+1; i++) cout<<df[i]<<" ";
  if (df[K] == 1)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define F first
#define S second
// cout<<fixed<<setprecision(11);
const string nl = "\n";
const ll MOD = 1e9 + 7;
const ll ARR_MAX = 1e5 + 1;
const ll INF = 1e14;
bool dp[ARR_MAX]; // dp[i]=1 if player playing now will win. =0 if he will lose.

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

  for (int i = a[0]; i <= k; i++) {
    bool f = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] >= i) {
        f = f || !(dp[i - a[j]]);
      }
    }
    dp[i] = f;
  }
  // for(int i=0;i<=k;i++){
  // 	cout<<dp[i]<<" ";
  // }
  // cout<<nl;
  if (dp[k] == 0) {
    cout << "Second" << nl;
  } else {
    cout << "First" << nl;
  }
}

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define F first
#define S second
// cout<<fixed<<setprecision(11);
const string nl = "\n";
const ll MOD = 1e9 + 7;
const ll ARR_MAX = 1e5 + 1;
const ll INF = 1e14;
bool dp[ARR_MAX]; // dp[i]=1 if player playing now will win. =0 if he will lose.

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

  for (int i = a[0]; i <= k; i++) {
    bool f = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] <= i) {
        f = f || !(dp[i - a[j]]);
      }
    }
    dp[i] = f;
  }
  // for(int i=0;i<=k;i++){
  // 	cout<<dp[i]<<" ";
  // }
  // cout<<nl;
  if (dp[k] == 0) {
    cout << "Second" << nl;
  } else {
    cout << "First" << nl;
  }
}

int main() {
  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;

#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)
#define E "\n"
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define MAX 1e5
#define MIN -1e5

const int N = 1e5 + 2;
int n, k;
vector<int> a;
int dp[N][2];

int solve(int x, int k) {
  if (k < a[0])
    return 1 - x;

  if (dp[k][x] != -1)
    return dp[k][x];

  int ans = 1 - x;

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

  {
    if (a[i] <= k) {
      if (solve(1 - x, k - a[i]) == x) {
        ans = x;
        break;
      }
    } else
      break;
  }
  return dp[k][x] = ans;
}

int32_t main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  cin >> n >> k;
  a.resize(n);

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


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

#define int long long
#define f(i, l, n) for (int i = l; i < n; i++)
#define E "\n"
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define MAX 1e5
#define MIN -1e5

const int N = 1e5 + 2;
int n, k;
vector<int> a;
int dp[N][2];

int solve(int x, int k) {
  if (k < a[0])
    return 1 - x;

  if (dp[k][x] != -1)
    return dp[k][x];

  int ans = 1 - x;

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

  {
    if (a[i] <= k) {
      if (solve(1 - x, k - a[i]) == x) {
        ans = x;
        break;
      }
    } else
      break;
  }
  return dp[k][x] = ans;
}

int32_t main() {

  cin >> n >> k;
  a.resize(n);

  f(i, 0, N) f(j, 0, 2) dp[i][j] = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (solve(0, k) == 0)
    cout << "First\n";
  else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k>>
#define pai(k) pair<k, k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x, y) unordered_map<x, y>

int solve(int *arr, int n, int k) {
  int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j >= arr[i - 1])
        dp[i][j] = dp[i][j] | (!dp[i][j - arr[i - 1]]);
    }
  }
  return dp[n][k];
}
int solveagain(int *arr, int n, int k) {
  int dp[k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      dp[i] = dp[i] | (i >= arr[j]) ? (!dp[i - arr[j]]) : 0;
    }
  }
  return dp[k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, x, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = solveagain(arr, n, k);
  if (ans)
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k>>
#define pai(k) pair<k, k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x, y) unordered_map<x, y>

int solve(int *arr, int n, int k) {
  int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j >= arr[i - 1])
        dp[i][j] = dp[i][j] | (!dp[i][j - arr[i - 1]]);
    }
  }
  return dp[n][k];
}
int solveagain(int *arr, int n, int k) {
  int dp[k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (i < arr[j])
        continue;
      if (dp[i - arr[j]] == 0)
        dp[i] = 1;
    }
  }
  return dp[k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, x, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = solveagain(arr, n, k);
  if (ans)
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}
Problem p03170 (C++)

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

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;

  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];

  vector<bool> stones(K + 3, false);

  // 1,2, ... Kまでの値で
  // それぞれ先手必勝or後手必勝７日を調べる
  // 答えはstones[K]により判定される
  // stones[K] == trueならば　先手必勝である
  // stones[K] == falseならば　後手必勝である

  for (int i = 1; i <= K; i++) {

    for (int j = 0; j < N; j++) {

      if (stones[i - a[j]] == false && i - a[j] >= 0)
        stones[i] = true;
    }
  }

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


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

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;

  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];

  vector<bool> stones(K + 3, false);

  // 1,2, ... Kまでの値で
  // それぞれ先手必勝or後手必勝７日を調べる
  // 答えはstones[K]により判定される
  // stones[K] == trueならば　先手必勝である
  // stones[K] == falseならば　後手必勝である

  for (int i = 1; i <= K; i++) {

    for (int j = 0; j < N; j++) {

      if (i - a[j] >= 0 && stones[i - a[j]] == false)
        stones[i] = true;
    }
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)

int dp[100010];
int a[110];

int main() {
  int n, k;
  cin >> n >> k;

  REP(i, n) { cin >> a[i]; }

  REP(i, k + 1) { dp[i] = 0; }

  REP(i, k) {
    if (i < a[0]) {
      dp[i] = -1;
    }

    REP(j, n) {
      if (dp[i + a[j]] != 1) {
        dp[i + a[j]] = -dp[i];
      }
    }
  }

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


Fixed submission:
#include <iostream>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)

int dp[100010];
int a[110];

int main() {
  int n, k;
  cin >> n >> k;

  REP(i, n) { cin >> a[i]; }

  REP(i, k + 1) { dp[i] = 0; }

  REP(i, k) {
    if (i < a[0]) {
      dp[i] = -1;
    }

    REP(j, n) {
      if (i + a[j] > k)
        continue;
      if (dp[i + a[j]] != 1) {
        dp[i + a[j]] = -dp[i];
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#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;
#define AB_BHI_NI_DEGI                                                         \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
// int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set                                                            \
  tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1) {
  cout << n << "\n";
  exit(0);
}
int n, k;
int a[103];
int dp[N];

int fun(int rem) {
  if (dp[N])
    return dp[N];
  for (int i = 1; i <= n; i++) {
    if (rem >= a[i]) {
      if (fun(rem - a[i]) == 2) {
        dp[rem] = 1;
        return dp[rem];
      }
    }
  }
  return dp[rem] = 2;
}

int32_t main() {
  AB_BHI_NI_DEGI
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0] = 2;
  int x = fun(k);
  if (x == 1)
    cout << "First\n";
  else
    cout << "Second\n";

  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;
#define AB_BHI_NI_DEGI                                                         \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
// int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set                                                            \
  tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1) {
  cout << n << "\n";
  exit(0);
}
int n, k;
int a[103];
int dp[N];

int fun(int rem) {
  if (dp[rem])
    return dp[rem];
  for (int i = 1; i <= n; i++) {
    if (rem >= a[i]) {
      if (fun(rem - a[i]) == 2) {
        dp[rem] = 1;
        return dp[rem];
      }
    }
  }
  return dp[rem] = 2;
}

int32_t main() {
  AB_BHI_NI_DEGI
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  dp[0] = 2;
  int x = fun(k);
  if (x == 1)
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}
Problem p03170 (C++)

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

int main() {

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

  vector<bool> dp(k + 1, false);

  for (int i = a[0]; i < dp.size(); i++) {
    rep(j, a.size()) {
      if (dp[i - a[j]] == false) {
        dp[i] = true;
        break;
      }
    }
  }

  printf("%s", dp[k] == true ? "First" : "Second");
  return 0;
}

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

int main() {

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

  vector<bool> dp(k + 1, false);

  for (int i = a[0]; i < dp.size(); i++) {
    rep(j, a.size()) {
      if (i - a[j] >= 0 && dp[i - a[j]] == false) {
        dp[i] = true;
        break;
      }
    }
  }

  printf("%s", dp[k] == true ? "First" : "Second");
  return 0;
}