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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back

void solve();

int main() {
  // freopen("schools.in", "r", stdin);
  // freopen("schools.out", "w", stdout);
  ios_base::sync_with_stdio(0), cin.tie(0);
  // cout << fixed << setprecision(10);
  int t;
  // cin >> t;
  t = 1;
  while (t--)
    solve();
  return 0;
}

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

bool dfs(int balance) {
  if (dp[balance] != -1)
    return dp[balance];
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i] <= balance)
      ans |= !dfs(balance - a[i]);
  return dp[balance] = ans;
}

void solve() {
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  cout << (dfs(k) ? "First\n" : "Second\n");
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back

void solve();

int main() {
  // freopen("schools.in", "r", stdin);
  // freopen("schools.out", "w", stdout);
  ios_base::sync_with_stdio(0), cin.tie(0);
  // cout << fixed << setprecision(10);
  int t;
  // cin >> t;
  t = 1;
  while (t--)
    solve();
  return 0;
}

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

bool dfs(int balance) {
  if (dp[balance] != -1)
    return dp[balance];
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i] <= balance)
      ans |= !dfs(balance - a[i]);
  return dp[balance] = ans;
}

void solve() {
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  cout << (dfs(k) ? "First\n" : "Second\n");
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

vector<vector<int>> dp;

int n, k;
vector<int> arr;

int solve(int left = k, int chance = 0) {
  if (dp[chance][left] != -1) {
    return dp[chance][left];
  }
  int ans = chance;
  for (int i = 0; i < n; i++) {
    int temp = left - arr[i];
    if (temp >= 0 && temp < arr[0]) {
      dp[chance][left] = chance;
      return chance;
    }
  }
  for (int i = 0; i < n; i++) {
    if (solve(left - arr[i], !chance) == chance) {
      dp[chance][left] = chance;
    }
  }
  if (dp[chance][left] == -1) {
    dp[chance][left] = !chance;
  }
  return dp[chance][left];
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  dp.assign(2, vector<int>(k + 1, -1));
  arr.assign(n + 1, 0);
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  int ans = solve();
  // cout << dp << endl;
  cout << (ans ? "Second" : "First") << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

vector<vector<int>> dp;

int n, k;
vector<int> arr;

int solve(int left = k, int chance = 0) {
  if (dp[chance][left] != -1) {
    return dp[chance][left];
  }
  int ans = chance;
  for (int i = 0; i < n; i++) {
    int temp = left - arr[i];
    if (temp >= 0 && temp < arr[0]) {
      dp[chance][left] = chance;
      return chance;
    }
  }
  for (int i = 0; i < n; i++) {
    if (left >= arr[i] && (solve(left - arr[i], !chance) == chance)) {
      dp[chance][left] = chance;
    }
  }
  if (dp[chance][left] == -1) {
    dp[chance][left] = !chance;
  }
  return dp[chance][left];
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  dp.assign(2, vector<int>(k + 1, -1));
  arr.assign(n + 1, 0);
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  int ans = solve();
  // cout << dp << endl;
  cout << (ans ? "Second" : "First") << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  vector<bool> dp(n + 1, 0);
  for (int i = 0; i <= k; i++) {
    for (int a : v) {
      if (i - a >= 0 && !dp[i - a])
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First";
  else
    cout << "Second";
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  vector<bool> dp(k + 1, 0);
  for (int i = 0; i <= k; i++) {
    for (int a : v) {
      if (i - a >= 0 && !dp[i - a])
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First";
  else
    cout << "Second";
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
string solve(int arr[], int k, int n) {

  vector<bool> dp(k + 1, 0);
  for (int i = 1; i <= k; i++) {

    for (int j = 0; j < n; j++) {
      if (i >= j) {
        if (dp[i - arr[j]] == 0)
          dp[i] = 1;
      }
    }
  }
  return dp[k] ? "First" : "Second";
}

int main() {
  // code

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
string solve(int arr[], int k, int n) {

  vector<bool> dp(k + 1, 0);
  for (int i = 1; i <= k; i++) {

    for (int j = 0; j < n; j++) {
      if (i >= arr[j]) {
        if (dp[i - arr[j]] == 0)
          dp[i] = 1;
      }
    }
  }
  return dp[k] ? "First" : "Second";
}

int main() {
  // code

  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  cout << solve(arr, k, n) << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
const int INF = 1e9;

int main() {
  fast int n, K;
  cin >> n >> K;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> dp(100001, false);
  for (int k = 0; k < n; k++) {
    for (int x = 0; x <= K; x++) {
      if (!dp[x])
        dp[x + a[k]] = true;
    }
  }
  if (dp[K])
    cout << "First";
  else
    cout << "Second";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
const int INF = 1e9;

int main() {
  fast int n, K;
  cin >> n >> K;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<bool> dp(K + 1, false);
  for (int x = 0; x <= K; x++) {
    for (int k = 0; k < n; k++) {
      if (x + a[k] <= K) {
        if (!dp[x])
          dp[x + a[k]] = true;
      }
    }
  }
  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;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
template <class T> inline int chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline int chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 58;
constexpr int mod = 1000000007;

bool dp[100010];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  for (int i = 0; i < k; i++) {
    if (dp[i])
      continue;
    for (int j = 0; j < n; j++) {
      dp[i + A[j]] = 1;
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
template <class T> inline int chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline int chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 58;
constexpr int mod = 1000000007;

bool dp[200010];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
    cin >> A[i];
  for (int i = 0; i < k; i++) {
    if (dp[i])
      continue;
    for (int j = 0; j < n; j++) {
      dp[i + A[j]] = 1;
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
}
Problem p03170 (C++)

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

using namespace std;

typedef long long ll;

const int MAX = 107;

int a[MAX];
int g[MAX * MAX * MAX];

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

  return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX = 107;

int a[MAX];
int g[MAX * MAX * MAX];

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

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
// author:-*mdragneell*

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

#define ll long long
#define ld long double
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>

int const N = 3001;
ll min(ll x, ll y) {
  if (x < y)
    return x;
  else
    return y;
}
ll max(ll x, ll y) {
  if (x > y)
    return x;
  else
    return y;
}

ll cache[N];
ll n, k, a[N];

ll sol(ll k) {
  if (k == 0)
    return 0;
  if (cache[k] != -1)
    return cache[k];

  cache[k] = 0;

  for (int i = 0; i < n; i++) {
    if (k < a[i])
      break;
    cache[k] |= (sol(k - a[i]) == 0);
  }
  return cache[k];
}

int main() {
  ll i, j;
  cin >> n >> k;

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

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

  if (sol(k))
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}


Fixed submission:
// author:-*mdragneell*

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

#define ll long long
#define ld long double
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>

int const N = 100005;
ll min(ll x, ll y) {
  if (x < y)
    return x;
  else
    return y;
}
ll max(ll x, ll y) {
  if (x > y)
    return x;
  else
    return y;
}

ll cache[N];
ll n, k, a[N];

ll sol(ll k) {
  if (k == 0)
    return 0;
  if (cache[k] != -1)
    return cache[k];

  cache[k] = 0;

  for (int i = 0; i < n; i++) {
    if (k < a[i])
      break;
    cache[k] |= (sol(k - a[i]) == 0);
  }
  return cache[k];
}

int main() {
  ll i, j;
  cin >> n >> k;

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

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

  if (sol(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];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int dp[k + 1];
  dp[0] = 0;
  int i = 1;
  while (i < a[0]) {
    dp[i] = 0;
    i++;
  }

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

  for (int i = a[0]; 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;
    }
  }
  cout << (dp[k] ? "First" : "Second") << endl;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define loop(i, a, b) for (lli i = a; i <= b; ++i)
#define fast                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define lli long long int
using namespace std;

signed main() {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  fast;
  int n, k;
  cin >> n >> k;
  int x[n];
  loop(i, 0, n - 1) cin >> x[i];
  bool a[k + 1];
  loop(i, 0, k) {
    bool ans = false;
    loop(j, 0, n - 1) {

      if (i - x[j] >= 0) {
        ans = ans || (a[i - x[j]] == 0);
      }
    }
    a[i] = ans;
  }
  cout << (a[k] ? "First" : "Second") << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define loop(i, a, b) for (lli i = a; i <= b; ++i)
#define fast                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define lli long long int
using namespace std;

signed main() {
  fast;
  int n, k;
  cin >> n >> k;
  int x[n];
  loop(i, 0, n - 1) cin >> x[i];
  bool a[k + 1];
  loop(i, 0, k) {
    bool ans = false;
    loop(j, 0, n - 1) {

      if (i - x[j] >= 0) {
        ans = ans || (a[i - x[j]] == 0);
      }
    }
    a[i] = ans;
  }
  cout << (a[k] ? "First" : "Second") << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010; // 10^18 = 2^60
int INF = 2000000000;          // 10^9
ll MOD = 1000000007;

vector<bool> W(100010);

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i <= K; i++) {
    if (W.at(i) == 0) {
      for (int j = 0; j < N; j++) {
        W.at(i + a.at(j)) = 1;
      }
    }
  }
  if (W.at(K)) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010; // 10^18 = 2^60
int INF = 2000000000;          // 10^9
ll MOD = 1000000007;

vector<bool> W(100010);

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i <= K; i++) {
    if (W.at(i) == 0) {
      for (int j = 0; j < N; j++) {
        if (i + a.at(j) < 100010) {
          W.at(i + a.at(j)) = 1;
        }
      }
    }
  }
  if (W.at(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;
  bool dp[k + 1];
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  dp[0] = false;
  for (int i = 1; i < k + 1; i++) {
    dp[i] = false;
    for (int j = 0; j < n; j++) {
      if (a[j] <= k) {
        if (!dp[i - a[j]])
          dp[i] = !dp[i - a[j]];
      }
    }
  }
  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;
  bool dp[k + 1];
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  dp[0] = false;
  for (int i = 1; i < k + 1; i++) {
    dp[i] = false;
    for (int j = 0; j < n; j++) {
      if (a[j] <= i) {
        if (!dp[i - a[j]])
          dp[i] = !dp[i - a[j]];
      }
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
}
Problem p03170 (C++)

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

#define DRACARYS                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cin.exceptions(cin.failbit);                                                 \
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 1e5 + 10;
const long long int MINN = 1e5 + 10;
const long long int inf = 1e18 + 7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;

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

int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  DRACARYS
  cin >> n >> k;
  repA(i, 1, n) cin >> a[i];
  repA(i, 0, k) repA(j, 1, n) if (!dp[i]) dp[i + a[j]] = 1;
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}


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

#define DRACARYS                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cin.exceptions(cin.failbit);                                                 \
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 2e5 + 10;
const long long int MINN = 1e5 + 10;
const long long int inf = 1e18 + 7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef stack<int> st;

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

int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  DRACARYS
  cin >> n >> k;
  repA(i, 1, n) cin >> a[i];
  repA(i, 0, k) repA(j, 1, n) if (!dp[i]) dp[i + a[j]] = 1;
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define M 300002
#define N 1000000000000000003
#define endl "\n"
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, v;
  cin >> n >> v;
  ll arr[200004] = {0};
  ll var[200003] = {0};
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    var[arr[i]] = 1;
  }
  sort(arr, arr + n);

  for (ll i = arr[1]; i <= v; i++) {
    if (var[i] == 1) {
      continue;
    }

    for (ll j = 1; j <= n; j++) {
      if ((var[i - arr[j]] == 0) && (i - arr[j] >= 0)) {
        var[i] = 1;
        break;
      }
    }
  }

  if (var[v] == 1)
    cout << "First";
  else
    cout << "Second";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define M 300002
#define N 1000000000000000003
#define endl "\n"
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, v;
  cin >> n >> v;
  ll arr[200004] = {0};
  ll var[200003] = {0};
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    var[arr[i]] = 1;
  }
  sort(arr, arr + n);

  for (ll i = arr[1]; i <= v; i++) {
    if (var[i] == 1) {
      continue;
    }

    for (ll j = 1; j <= n; j++) {
      if (i - arr[j] >= 0) {
        if (var[i - arr[j]] == 0) {
          var[i] = 1;
          break;
        }
      }
    }
  }

  if (var[v] == 1)
    cout << "First";
  else
    cout << "Second";
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
/* Code by : Suraj (@suraj1611) */

#include <bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout << endl;
#define endl "\n"
#define F first
#define S second
#define label cout << "hello!" << endl
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

ll power(ll x, ll y) {
  ll m = md;
  ll ans = 1;
  while (y > 0) {
    if (y & 1)
      ans = (ans * x) % m;
    x = (x * x) % m;
    y >>= 1;
  }
  return ans;
}

int main() {
  IOS

      ll n,
      k;
  cin >> n >> k;
  ll a[n];
  rep(i, n) cin >> a[i];

  bool dp[n + 1];
  fill(dp, dp + 1, 0);

  rep(i, k + 1) {
    for (auto j : a) {
      if ((i - j) >= 0 and !dp[i - j])
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}

Fixed submission:
/* Code by : Suraj (@suraj1611) */

#include <bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout << endl;
#define endl "\n"
#define F first
#define S second
#define label cout << "hello!" << endl
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

ll power(ll x, ll y) {
  ll m = md;
  ll ans = 1;
  while (y > 0) {
    if (y & 1)
      ans = (ans * x) % m;
    x = (x * x) % m;
    y >>= 1;
  }
  return ans;
}

int main() {
  IOS

      ll n,
      k;
  cin >> n >> k;
  ll a[n];
  rep(i, n) cin >> a[i];

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

  rep(i, k + 1) {
    for (auto j : a) {
      if ((i - j) >= 0 and !dp[i - j])
        dp[i] = 1;
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[1000005], f[1000005];
int solve(int x) {
  if (f[x] != -1)
    return f[x];
  if (x == 0)
    return f[x] = 0;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= a[i])
      ret |= (solve(x - a[i]) ^ 1);
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  memset(f, -1, sizeof(f));
  puts(solve(k) ? "First" : "Second");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[1000005], f[1000005];
int solve(int x) {
  if (f[x] != -1)
    return f[x];
  if (x == 0)
    return f[x] = 0;
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= a[i])
      ret |= (solve(x - a[i]) ^ 1);
  }
  return f[x] = ret;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  memset(f, -1, sizeof(f));
  puts(solve(k) ? "First" : "Second");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>#De
#define DIM 107
#define INF 1000000007
using namespace std;

long long n, k, a[DIM], used[DIM];
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; j <= n; ++j)
      if (i >= a[j] && used[i - a[j]] == 0)
        used[i] = 1;

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

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>#De
#define DIM 107
#define INF 1000000007
using namespace std;

long long n, k, a[DIM], used[100007];
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; j <= n; ++j)
      if (i >= a[j] && used[i - a[j]] == 0)
        used[i] = 1;

  if (used[k])
    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 unsigned long long ull;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPi(i, a, b) for (int i = int(a); i < int(b); i++)
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;
}
const ll MOD = 1e9 + 7;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }

  vector<int> DP(K + 1000);
  REP(i, K + 1) {
    REP(j, N) {
      ll a = A[j];
      if (DP[i] == 0)
        DP[i + a] = 1;
    }
  }

  ll ans = DP[K];

  if (ans == 0)
    cout << "Second" << endl;
  else
    cout << "First" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPi(i, a, b) for (int i = int(a); i < int(b); i++)
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;
}
const ll MOD = 1e9 + 7;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }

  vector<int> DP(K + 1000);
  REP(i, K + 1) {
    REP(j, N) {
      ll a = A[j];
      if (i + a > K)
        continue;
      if (DP[i] == 0)
        DP[i + a] = 1;
    }
  }

  ll ans = DP[K];

  if (ans == 0)
    cout << "Second" << endl;
  else
    cout << "First" << endl;

  return 0;
}
Problem p03170 (C++)

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

vector<int> grundy(100005, -1);

int getMax(set<int> s) {
  int max = 0;
  while (s.find(max) != s.end())
    max++;
  return max;
}

int getGrundy(int pos, int *a, int n) {
  if (grundy[pos] != -1)
    return grundy[pos];
  set<int> s;
  for (int i = 0; i < n; i++) {
    if (a[i] > pos)
      break;
    int res = getGrundy(pos - a[i], a, n);
    s.insert(res);
  }
  return getMax(s);
}

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  grundy[0] = 0;
  grundy[k] = getGrundy(k, a, n);
  if (grundy[k])
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}

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

vector<int> grundy(100005, -1);

int getMax(set<int> s) {
  int max = 0;
  while (s.find(max) != s.end())
    max++;
  return max;
}

int getGrundy(int pos, int *a, int n) {
  if (grundy[pos] != -1)
    return grundy[pos];
  set<int> s;
  for (int i = 0; i < n; i++) {
    if (a[i] > pos)
      break;
    int res = getGrundy(pos - a[i], a, n);
    s.insert(res);
  }
  return grundy[pos] = getMax(s);
}

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  grundy[0] = 0;
  grundy[k] = getGrundy(k, a, n);
  if (grundy[k])
    cout << "First\n";
  else
    cout << "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> posnum(n);
  for (int i = 0; i < n; i++)
    cin >> posnum[i];
  vector<bool> dp(k + 1, false);
  for (int stone = 1; stone <= k; stone++) {
    for (int num = 0; num < n; num++) {
      if (dp[stone - posnum[num]] == false) {
        dp[stone] = true;
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First";
  else
    cout << "Second";
  cout << endl;
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> posnum(n);
  for (int i = 0; i < n; i++)
    cin >> posnum[i];
  vector<bool> dp(k + 1, false);
  for (int stone = 1; stone <= k; stone++) {
    for (int num = 0; num < n; num++) {
      if (stone >= posnum[num] && dp[stone - posnum[num]] == false) {
        dp[stone] = true;
        break;
      }
    }
  }
  if (dp[k] == true)
    cout << "First";
  else
    cout << "Second";
  cout << endl;
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n, k, v[103];
bool viz[1 << 17];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> v[i];
  for (int i = 0; i <= k; ++i)
    if (!viz[i])
      for (int j = 1; j <= n; ++j)
        viz[i + v[j]] = 1;
  if (viz[k])
    cout << "First";
  else
    cout << "Second";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n, k, v[103];
bool viz[1 << 17];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> v[i];
  for (int i = 0; i <= k; ++i)
    if (!viz[i])
      for (int j = 1; j <= n; ++j)
        viz[min(i + v[j], k + 1)] = 1;
  if (viz[k])
    cout << "First";
  else
    cout << "Second";
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;
int n, k, d[NMAX], maxim, a[NMAX];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int j = 0; j <= k; j) {
    if (d[j] == 0) {
      for (int i = 1; i <= n; i++) {
        if (j + a[i] <= k)
          d[j + a[i]] = 1;
      }
    }
  }
  if (d[k])
    cout << "First";
  else
    cout << "Second";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;
int n, k, d[NMAX], maxim, a[NMAX];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int j = 0; j <= k; j++) {
    if (d[j] == 0) {
      for (int i = 1; i <= n; i++) {
        if (j + a[i] <= k)
          d[j + a[i]] = 1;
      }
    }
  }
  if (d[k])
    cout << "First";
  else
    cout << "Second";
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long LL;
typedef pair<LL, LL> P;
const LL mod = 1e9 + 7;
const LL LINF = 1LL << 62;
const int INF = 1000000000;

vector<int> a;
int memo[100001][2];
int N;

int dfs(int k, int c) {
  if (memo[k][c] == 0)
    return memo[k][c];
  for (int i = 0; i < N; i++) {
    if (k - a[i] < 0)
      break;
    if (c) {
      if (dfs(k - a[i], c ^ 1))
        return memo[k][c] = c;
    } else {
      if (!dfs(k - a[i], c ^ 1))
        return memo[k][c] = c;
    }
  }
  return memo[k][c] = c ^ 1;
}

int main() {
  int K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a.pb(x);
  }
  memset(memo, -1, sizeof(memo));
  if (dfs(K, 1))
    puts("First");
  else
    puts("Second");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long LL;
typedef pair<LL, LL> P;
const LL mod = 1e9 + 7;
const LL LINF = 1LL << 62;
const int INF = 1000000000;

vector<int> a;
int memo[100001][2];
int N;

int dfs(int k, int c) {
  if (~memo[k][c])
    return memo[k][c];
  for (int i = 0; i < N; i++) {
    if (k - a[i] < 0)
      break;
    if (c) {
      if (dfs(k - a[i], c ^ 1))
        return memo[k][c] = c;
    } else {
      if (!dfs(k - a[i], c ^ 1))
        return memo[k][c] = c;
    }
  }
  return memo[k][c] = c ^ 1;
}

int main() {
  int K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a.pb(x);
  }
  memset(memo, -1, sizeof(memo));
  if (dfs(K, 1))
    puts("First");
  else
    puts("Second");
  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
//__professor_
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define test                                                                   \
  ll t;                                                                        \
  cin >> t;                                                                    \
  while (t--)
#define mod 1000000007
#define inf 1000000000000000001
const double pi = 3.141592653589793238463;
using namespace std;

int main() {
  FAST;
  ll n, k;
  cin >> n >> k;
  ll arr[n];
  ll min = INT_MAX;
  for (ll i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] < min)
      min = arr[i];
  }

  ll ans[k + 1];
  for (ll i = 0; i <= k; i++) {
    ans[i] = -1;
  }
  for (ll i = 0; i < n; i++) {
    ans[arr[i]] = 0;
  }

  for (ll i = 0; i < min; i++) {
    ans[i] = 1;
  }

  for (ll i = min + 1; i <= k; i++) {
    ll f = 0;
    if (ans[i] == -1) {

      for (ll j = 0; j < n; j++) {
        if (ans[i - arr[j]] == 1) {
          f = 1;
          break;
        }
      }

      if (f == 1) {
        ans[i] = 0;
      } else {
        ans[i] = 1;
      }
    }
  }

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

  // for(ll i=0;i<=k;i++)
  // 	cout<<ans[i]<<" ";

  return 0;
}


Fixed submission:
//__professor_
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define test                                                                   \
  ll t;                                                                        \
  cin >> t;                                                                    \
  while (t--)
#define mod 1000000007
#define inf 1000000000000000001
const double pi = 3.141592653589793238463;
using namespace std;

int main() {
  FAST;
  ll n, k;
  cin >> n >> k;
  ll arr[n];
  ll min = INT_MAX;
  for (ll i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] < min)
      min = arr[i];
  }

  ll ans[k + 1];
  for (ll i = 0; i <= k; i++) {
    ans[i] = -1;
  }
  for (ll i = 0; i < n; i++) {
    ans[arr[i]] = 0;
  }

  for (ll i = 0; i < min; i++) {
    ans[i] = 1;
  }

  for (ll i = min + 1; i <= k; i++) {
    ll f = 0;
    if (ans[i] == -1) {

      for (ll j = 0; j < n; j++) {
        if ((i - arr[j]) >= 0) {
          if (ans[i - arr[j]] == 1) {
            f = 1;
            break;
          }
        }
      }

      if (f == 1) {
        ans[i] = 0;
      } else {
        ans[i] = 1;
      }
    }
  }

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

  // for(ll i=0;i<=k;i++)
  // 	cout<<ans[i]<<" ";

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(), v.end()
#define CHAL_BAAP_KO_MT_SIKHA                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0
*/
const int N = 2e2;
int dp[N + 1], a[N + 1];
signed main() {

  CHAL_BAAP_KO_MT_SIKHA
  int n, k;
  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] |= (!dp[i - a[j]]);
    }
  }
  if (dp[k]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(), v.end()
#define CHAL_BAAP_KO_MT_SIKHA                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0
*/
const int N = 2e5;
int dp[N], a[101];
signed main() {

  CHAL_BAAP_KO_MT_SIKHA
  int n, k;
  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] |= (!dp[i - a[j]]);
    }
  }
  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;

// const int N = 100000, MAXI = 3, D = 1000;

// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10000, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	n = rand()%N + 1;

//     	cout << n << "\n~\n";

//     }

//     return 0;
// }

//---------------------------------------------//

/*
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */

//  /* while(!cin.eof()) */

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9 + 7)
#define MAXI (int)(3e17 + 10)
#define N 105
#define M 100005

int dp[M];

int n, k, a[N];

// Driver code to test above functions
int32_t main() {
#ifndef ONLINE_JUDGE
  // for getting input from inpu.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);

  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) {
        if (!dp[i - a[j]]) {
          dp[i] = 1;
          break;
        }
      }
    }
  }

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

  return 0;
}

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

// const int N = 100000, MAXI = 3, D = 1000;

// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10000, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	n = rand()%N + 1;

//     	cout << n << "\n~\n";

//     }

//     return 0;
// }

//---------------------------------------------//

/*
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */

//  /* while(!cin.eof()) */

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9 + 7)
#define MAXI (int)(3e17 + 10)
#define N 105
#define M 100005

int dp[M];

int n, k, a[N];

// Driver code to test above functions
int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);

  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) {
        if (!dp[i - a[j]]) {
          dp[i] = 1;
          break;
        }
      }
    }
  }

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

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int const MAXN = 110, MAXK = 110000;
int n, k, v[MAXN];
bool dp[MAXN];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  for (int i = 1; i <= k; i++) {
    bool possible = false;
    for (int j = 0; j < n && i - v[j] >= 0 && !dp[i]; j++)
      if (!dp[i - v[j]])
        dp[i] = true;
  }
  cout << (dp[k] ? "First" : "Second");
}

Fixed submission:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int const MAXN = 110, MAXK = 110000;
int n, k, v[MAXN];
bool dp[MAXK];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> v[i];
  for (int i = 1; i <= k; i++) {
    bool possible = false;
    for (int j = 0; j < n && i - v[j] >= 0 && !dp[i]; j++)
      if (!dp[i - v[j]])
        dp[i] = true;
  }
  cout << (dp[k] ? "First" : "Second");
}
Problem p03170 (C++)

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

int N, K;
vector<int> a;
vector<bool> dp;

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

  cin >> N >> K;
  a.resize(N);
  dp.resize(K + 1, false);
  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]) {
        continue;
      }
      if (i < a[j]) {
        continue;
      }
      if (!dp[j - a[i]]) {
        dp[i] = true;
      }
    }
  }
  (dp[K]) ? cout << "First" : cout << "Second";

  return 0;
}


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

int N, K;
vector<int> a;
vector<bool> dp;

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

  cin >> N >> K;
  a.resize(N);
  dp.resize(K + 1, false);
  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]) {
        continue;
      }
      if (i < a[j]) {
        continue;
      }
      if (!dp[i - a[j]]) {
        dp[i] = true;
      }
    }
  }
  (dp[K]) ? cout << "First" : cout << "Second";

  return 0;
}
Problem p03170 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 105;
int n, k, a[N], dp[N];
int dfs(int x) {
  if (~dp[x])
    return dp[x];
  bool win = 0;
  for (int i = 1; i <= n; ++i) {
    if (x - a[i] < 0)
      continue;
    win |= (dfs(x - a[i]) == 0);
  }
  return dp[x] = win;
}
int main() {
  memset(dp, -1, sizeof dp);
  dp[0] = 0; // 0先手败 大于0先手胜
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  puts(dfs(k) ? "First" : "Second");
  // for(int i=1;i<=5;++i)
  // printf("%d:%d\n",i,dp[i]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 105, K = 1e5 + 10;
int n, k, a[N], dp[K];
int dfs(int x) {
  if (~dp[x])
    return dp[x];
  bool win = 0;
  for (int i = 1; i <= n; ++i) {
    if (x - a[i] < 0)
      continue;
    win |= (dfs(x - a[i]) == 0);
  }
  return dp[x] = win;
}
int main() {
  memset(dp, -1, sizeof dp);
  dp[0] = 0; // 0先手败 大于0先手胜
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  puts(dfs(k) ? "First" : "Second");
  // for(int i=1;i<=5;++i)
  // printf("%d:%d\n",i,dp[i]);
  return 0;
}
Problem p03170 (C++)

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

int dp[100001][2], a[101], n;

// p = {0, 1} : {first, second}

int recur(int k, bool p) {
  if (k < a[0])
    return not p;

  int &ret = dp[k][p];
  for (int i = 0; i < n and k - a[i] >= 0; ++i)
    if (recur(k - a[i], not p) == p)
      return ret = p;

  return ret = not p;
}

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

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

  memset(dp, -1, sizeof dp);
  cout << (recur(k, 0) == 0 ? "First" : "Second") << endl;
  return 0;
}

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

int dp[100001][2], a[101], n;

// p = {0, 1} : {first, second}

int recur(int k, bool p) {
  if (k < a[0])
    return not p;

  int &ret = dp[k][p];
  if (ret != -1)
    return ret;

  for (int i = 0; i < n and k - a[i] >= 0; ++i)
    if (recur(k - a[i], not p) == p)
      return ret = p;

  return ret = not p;
}

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

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

  memset(dp, -1, sizeof dp);
  cout << (recur(k, 0) == 0 ? "First" : "Second") << endl;
  return 0;
}