Problem:


Score : 100 points

Problem Statement

There is a set A = \{ a_1, a_2, \ldots, a_N \} consisting of N positive integers.
Taro and Jiro will play the following game against each other.

Initially, we have a pile consisting of K stones.
The two players perform the following operation alternately, starting from Taro:

Choose an element x in A, and remove exactly x stones from the pile.

A player loses when he becomes unable to play.
Assuming that both players play optimally, determine the winner.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq K \leq 10^5

1 \leq a_1 < a_2 < \cdots < a_N \leq K

Input

Input is given from Standard Input in the following format:

N K
a_1 a_2 \ldots a_N

Output

If Taro will win, print First; if Jiro will win, print Second.

Sample Input 1

2 4
2 3

Sample Output 1

First

If Taro removes three stones, Jiro cannot make a move.
Thus, Taro wins.

Sample Input 2

2 5
2 3

Sample Output 2

Second

Whatever Taro does in his operation, Jiro wins, as follows:

If Taro removes two stones, Jiro can remove three stones to make Taro unable to make a move.

If Taro removes three stones, Jiro can remove two stones to make Taro unable to make a move.

Sample Input 3

2 7
2 3

Sample Output 3

First

Taro should remove two stones. Then, whatever Jiro does in his operation, Taro wins, as follows:

If Jiro removes two stones, Taro can remove three stones to make Jiro unable to make a move.

If Jiro removes three stones, Taro can remove two stones to make Jiro unable to make a move.

Sample Input 4

3 20
1 2 3

Sample Output 4

Second

Sample Input 5

3 21
1 2 3

Sample Output 5

First

Sample Input 6

1 100000
1

Sample Output 6

Second



Sample input:
2 4
2 3


Sample output:
First

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = IL()
A = IL()
a = A[0]

dp = [0 for i in range(K+1)]

for i in range(a,K+1):
  temp = [0]
  for a in A:
    if i >= a:
      temp.append(dp[i-a])
  if not max(temp):
    dp[i] = 1
      
if dp[-1]:
  print("First")
else:
  print("Second")

Submission status: Runtime Error

Solution code:
N,K =map(int,input().split())
List = list(map(int,input().split()))
DP = [False]*(2*K+1)
for i in range(K):
  for item in List:
    if DP[i]==False:
      DP[i+item] = True
if DP[k]==True:
  print('First')
else:
  print('Second')

Submission status: Runtime Error

Solution code:
def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  dp = ['Second']*(K*2)
  for i in range(K):
    if dp[i]!='Second':
      continue
    for j in range(N):
      dp[i+A[j]]='First'
  ans = dp[K]
  return ans
print(solve())def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  dp = ['Second']*(K*2)
  for i in range(K):
    if dp[i]!='Second':
      continue
    for j in range(N):
      dp[i+A[j]]='First'
  ans = dp[K]
  return ans
print(solve())

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h> 
using namespace std; 
#define M int(1e9+7)
#define int long long
#define lli long long int
#define I 10e5

int32_t main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout); 
   #endif
   int n, k;
   cin>>n>>k;
   vector<int> v(n);
   for(auto &i:v)
   {
      cin>>i;
   }
   bool dp[k+1];
   memset(dp, 0, sizeof(dp));
   for(int i=1;i<=k;i++)
   {
      for(int j=0;j<n;j++)
      {
         if(v[j]>i)
            continue;
         if(dp[i-v[j]]==0)
            dp[i] = 1;
      }
   }
   cout<<(dp[k]==0?"Second":"First");
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h> 
using namespace std; 
#define M int(1e9+7)
#define ll long long
#define lli long long int
#define I 10e5

int32_t main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout); 
   #endif
   int n, k;
   cin>>n>>k;
   vector<int> v(n);
   for(auto &i:v)
   {
      cin>>i;
   }
   int dp[k+1];
   memset(dp, 0, sizeof(dp));
   for(int i=1;i<=k;i++)
   {
      for(int j=0;j<n;j++)
      {
         if(v[j]>i)
            continue;
         if(dp[i-v[j]]==0)
            dp[i] = 1;
      }
   }
   cout<<(dp[k]==0?"Second":"First");
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = []
for i in range(n):
  a.append(int(input()))

dp = [False]*(k+1)
dp[0] = 0

for i in range(1,k+1):
  for j in range(n):
    if i-a[j] >= 0 and dp[i-a[j]] == 0:
      dp[i] = 1
      break
    #dp[i] = 0

if dp[k] == 1:
  print("First")
else:
  print("Second")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
dp = [-1]*100001
# dp[100000] = 0

def mex(l):
    l=list(set(l))
    d={}
    for i in l:
        d[i] = 1
    x=len(l)
    for i in range(0,len(l)):
        try :
            d[i] = d[i] + 1
        except:
            x=i
            break
    return x

def grundy(a,k):
    h = min(a)
    if k<h:
        return 0
    if k==h:
        return 1

    if dp[k]!=-1:
        return dp[k]
    
    dp[k] = mex([grundy(a,k-i) for i in a if k-i>=0])
    return dp[k]

if grundy(a,k) == 0:
    print("Second")
else:
    print("First")



# n=int(input())

# dp = [-1]*(1000001)
# dp[1] = 1

# for i in range(2,n):
#     if dp[i]!=-1:
#         break
#     x=min(6,i)
#     m=0
#     for j in range(1,x):
#         m=m+dp[i-j]
#     dp[i]=m
# print(dp[i])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
dp = [-1]*100001

def mex(l):
    l.sort()
    x=len(l)
    for i in range(0,x):
        if i!=l[i]:
            x=i
            break
    return x

def grundy(a,k):
    if k==0:
        return 0
    if dp[k]!=-1:
        return dp[k]
    
    dp[k] = mex([grundy(a,k-i) for i in a if k-i>=0])
    return dp[k]

if grundy(a,k) == 0:
    print("Second")
else:
    print("First")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = tuple(map(int, input().split()))

dp = [False]*(k+100)

for i in range(k):
  if dp[i] is False:
    for j in a:    
      dp[i+j] = True

print("First" if dp[k] else "Second")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map, (int, input().split()))
dp = [False] * k+1;
for i in range (1, k+1):
  for j in range(n):
    if i-a[j]<0:
      break;
    if dp[i-a[j]]==False:
      dp[i] = True;
      break;
if dp[k] == True:
  print("First");
else
  print("Second");

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
l = [0 for i in range(m+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
l = [0 for i in range(n+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
l = [0 for i in range(n+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()))]
l = [0 for i in range(n+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [0 for i in range(n+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [0 for i in range(n)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
arr=[int(i) for i in input().split()]
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,k+1):
        if arr[i-1]<=j:
            temp=0
            if dp[i][j-arr[i-1]]==0:
                temp=1
            dp[i][j]=temp
            else:
                dp[i][j]=dp[i-1][j]
if dp[n][k]==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
li=[int(k) for k in input().split()]
dp=[False]*(n+1)
for i in range(1,k+1):
  for j in range(len(li)):
    if i-li[j]<0:
      dp[i]=True
    else:
      if dp[i-li[j]]==False:
        dp[i]=True
if dp[k]==True:
  print("First")
else:
  print("Second")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
li=[int(k) for k in input().split()]
dp=[False]*(n+1)
for i in range(1,k+1):
  for j in range(len(li)):
    if i-li[j]<0:
      dp[i]=False
    else:
      if dp[i-li[j]]==False:
        dp[i]=True
if dp[k]==True:
  print("First")
else:
  print("Second")

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = [False]*(k+1)
for i in range(k+1):
  for aj in a:
    if i - aj >=0:
      if s[i-aj] == False:
        s[i] = True
        break
if a[k]==True:
  print("First")
else:
  print("Second")

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit
setrecursionlimit(1<<30)
def f(k,p):
    if k==0:
        return p^1
    if k<0:
        return p
    if d[k][p]==-1:
        d[k][p]=p if any(f(k-i,p^1)==p for i in a) else p^1
    return d[k][p]
n,k=map(int,raw_input().split())
d=[[-1]*2 for _ in xrange(k)]
a=map(int,raw_input().split())
print 'First' if f(k,0)==0 else 'Second'

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
dp=[False]*(k+1)
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[a]=True,求めるのはdp[k]
# dp[i]={dp[i-a]の中にひとつでもFalseがあればTrue、other->False}
# <=> すべてのai(in a)についてdp[i]=False->dp[i+ai]=True
for i in range(k+1):
      for ai in a:
            if i+ai<=k and not dp[i]:
                  dp[i+ai]=True
print('First' if dp[k] else 'Second')

Submission status: Runtime Error

Solution code:
def f(k):
    if k < 0:
        return True
    if k == 0:
        return False
    return any([not f(k-a) for a in A])


n, k = map(int, input().split())
*A, = map(int, input().split())
print(f(k))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1+1234)

for i in range(0,k+1):
    if dp[i] == 0:
        for x in a:
            dp[i+x] =1

print("First" if dp[k] else "Second")

Submission status: Runtime Error

Solution code:
def main():
    def f(k):
        if k < min_a:
            return False
        if k in a:
            return True
        if dp[k] != -1:
            return dp[k]
        for v in a:
            if k >= v:
                if not f(k-v):
                    dp[k] = True
                    return True
        dp[k] = False
        return False

    inp = lambda: [int(x) for x in input().split()]    
    n, k = inp()
    a = inp()
    min_a = min(a)
    dp = [-1] * (k+1)
    ans = "First" if f(k) else "Second"
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
l=[int(x) for x in input().split()]
l.sort(reverse=True)
a=l[0]
c=0
while(K>=a):
  K=K-a
  c=c+1
if K==0:
  if c%2!=0:
    print("Taro")
  else:
    print("Jiro")
else:
  if K in l:
    c=c+1
    if c%2!=0:
    print("Taro")
    else:
    print("Jiro")

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

dp = [-1 for i in range(n+1)]

dp[0] = -1

for i in range(1,n+1):
  if a[0] > i:
    dp[i] = -1
    continue
    
  for j in a:
    if dp[i-j] == -1:
      dp[i] = 1
      break

if dp[n] == -1:
  print('Second')
else:
  print('First')

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

# dp[i]: 残りがi個の状態で先手が勝つかどうか
dp = [-1 for _ in range(K+1)]

# dp[i] = 0: 残りi個で先手が負ける
# dp[i] = 1: 残りi個で先手が勝つ
# dp[i] = -1: 残りi個でも不明

for i in range(K + 1):
    # 遷移先: i-aで、そのとき手番は後手
    # どのi-aも1 = 後手がかならず勝つ = 負け
    # 1つでも0がある = 1つでも勝ち筋がある = (その手を打てば)勝ち
    # 
    # どのi-aにも遷移できない = 打てない = 負け
    if all([i - a < 0 for a in A]):
        dp[i] = 0
    else:
        if all([dp[i - a] == 1 for a in A]):
            dp[i] = 0
        elif any([dp[i - a] == 0 for a in A]):
            dp[i] = 1
        else:
            dp[i] |= int(not dp[i-a])

if dp[K]:
    print('First')
else:
    print('Second')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
      if n >= i:
		if fn(n-i) == 1:
			dp[n] = 0
			return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
# dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	if n == 0:
		dp[n] = 0
		return dp[n]
	ans = 0
	for i in L:
		if fn(n-i) == 0:
			ans = 1
			break
	dp[n] = ans		
	return dp[n]
for l in range(K):
	fn(l)
if fn(K) == 1:
	print("First")
else:
	print("Second")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
# dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	if n == 0:
		dp[n] = 0
		return dp[n]
	ans = 0
	for i in L:
		if fn(n-i) == 0:
			ans = 1
			break
	dp[n] = ans		
	return dp[n]
for l in range(K):
	fn(l)
if fn(K):
	print("First")
else:
	print("Second")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
# dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	if n == 0:
		dp[n] = 0
		return dp[n]
	ans = 0
	for i in L:
		if fn(n-i) == 0:
			ans = 1
			break
	dp[n] = ans		
	return dp[n]
for l in range(1, 	K):
	fn(l)
if fn(K):
	print("First")
else:
	print("Second")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
		if fn(n-i) == 1:
			dp[n] = 0
			return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
stones = list(map(int, input.split()))

dp = [False for _ in range(k+1)]

for i in range(k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print('First')
else:
  print('Second')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
stones = list(map(int, input.split()))

dp = [False for _ in range(k+1)]

for i in range(1, k+1):
  for j in stones:
    if i >= j and dp[i-j] == False:
      dp[i] = True
      continue
      
if dp[k]:
  print('First')
else:
  print('Second')

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
aa = list(map(int,input().split()))

dp = [-1]*(k+1)

for i in range(1,k+1):
  for j in range(n):
    if i >= aa[j]:
      dp[i] = max(dp[i],-dp[i-aa[j]])

if win[k]>0:
  print('first')  
else:
  print('second')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_a = max(A)

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

for i in range(max_a + 1, K + 1):
    for a in A:
        if dp[i - a] == 0:
            dp[i] = 1
            break
    else:
        dp[i] = 0

ans = "First" if dp[i] else "Second"
print(ans)

Submission status: Runtime Error

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

#define PI 3.1415926535897932
int n,k;
int a[100000];
int dp[100001];

bool rec(int rest) {
    if (~dp[rest]) return dp[rest];
    for (int i=0;i<n;i++) {
        if (rest-a[i]<0) continue;
        if (!rec(rest-a[i])) return dp[rest]=true;
    }
    return dp[rest]=false;
}

int main(){
    scanf("%d %d",&n,&k);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    memset(dp,-1,sizeof(dp));
    if (rec(k)) printf("First\n");
    else printf("Second\n");
    return 0;
}

Submission status: Runtime Error

Solution code:
 n, k = map(int, input().split( ))

a = list(map(int, input().split( )))

dp = [0]*(k+1)

for i in range(k+1):
    win = 0
    for j in a:
        if i>=j and dp[i-j] == 0:
            win = 1
            break
    dp[i] = win
#print(*dp)            
if dp[k] == 1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = [[-1]*2 for i in range(k+1)]

def solve(kLeft, player):
    if (kLeft<0):
        return player

    if (kLeft==0):
        return 1-player

    if (dp[kLeft][player]!=-1):
        return dp[kLeft][player]

    for i in range(n):
        x = solve(kLeft-a[i], 1-player)
        if (x==player):
            dp[kLeft][player] = player
            return dp[kLeft][player]
    dp[kLeft][player] = 1-player
    return dp[kLeft][player]


z = solve(k, 0)

if (z==0):
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
from functools import lru_cache

n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

# 1:先手　-1:後手
@lru_cache(maxsize=None)
def dp(x):
    for i in a:
        if x < i:
            return -1
        else:
            if dp(x-i) == -1:
                return 1
    return -1


if dp(k)==1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;

 //dp[i] - true if first player wins if there are i stones remaining

void solve()
{
ll n,k;
cin>>n>>k;
std::vector<ll> a(n);
for (int i = 0; i < n; ++i)
{
  cin>>a[i];
  /* code */
}
std::vector<bool> dp(k+1);
for (ll stones = 0; stones <= k  ; ++stones)
{
  for(auto it : a)
  {
    // agar dp[stones - k] true he to dusra wala player jit jayega
    if(stones>=it and !dp[stones - it])
    {
        dp[stones]  = 1;
    }
  }
}
if(dp[k])
  cout<<"First\n";
else cout<<"Second\n";

}

signed main(){
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }

Submission status: Runtime Error

Solution code:
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, K = mi()
a = lmi()
a.insert(0, -12)
dp = [False] * (K + 1)

for i in range(1, K + 1):
    for j in a:
        if i >= j and not dp[i - j]:
            dp[i] = True

if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

dp = [[[0.0 for _ in range(n+1)] for _ in range(n+1)] for _ in range(n+1)]

for z in range(c[3] + 1):
    for y in range(c[2]+1 + c[3] - z):
        for x in range(n+1 - z - y):
            if x + y + z == 0:
                continue
            ret = 0.0
            if x > 0:
                ret += dp[x-1][y][z] * x
            if y > 0:
                ret += dp[x+1][y-1][z] * y
            if z > 0:
                ret += dp[x][y+1][z-1] * z
            dp[x][y][z] = (ret + n) / (x + y + z)

print(dp[c[1]][c[2]][c[3]])

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

def f(N, A, K):
    dp = [0] * (K + 1)
    mina = min(A)
    minmax = mina + max(A)
    for i in range(mina, minmax):
        for x in A:
            i_ = i - x
            dp[i] = 1 if i_ < mina else dp[i_] ^ 1
            if dp[i]:
                break
    for i in range(minmax, K + 1):
        for x in A:
            dp[i] = dp[i - x] ^ 1
            if dp[i]:
                break
    return(dp[K])

ans = [ "Second", "First" ]
n, k = map(int, input().split()) # 1 <= n <= 100, 1 <= k <= 10^5
a = list(map(int, input().split()))
print(ans[f(n, a, k)])

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

memo = [-1] * (k+1)
def rec(x):
    if memo[x] >= 0:
        return memo[x]
    flag = 0
    for i in range(n):
        if x - a[i] < 0:
            continue
        if rec(x - a[i]) == 0:
            flag = 1
    if flag == 1:
        memo[x] = 1
        return 1
    else:
        memo[x] = 0
        return 0

if rec(k) == 1:
    print("First")
else:
    print("Second")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * (N*2+100) # 後手必勝のところが1

X[K] = 1
for i in range(K)[::-1]:
    for a in A:
        if X[i+a] == 1:
            break
    else:
        X[i] = 1
        
print(["First", "Second"][X[0]])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * (N+K+1000) # 後手必勝のところが1

X[K] = 1
for i in range(K)[::-1]:
    for a in A:
        if X[i+a] == 1:
            break
    else:
        X[i] = 1
        
print(["First", "Second"][X[0]])

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * (N+K+1) # 後手必勝のところが1

X[K] = 1
for i in range(K)[::-1]:
    for a in A:
        if X[i+a] == 1:
            break
    else:
        X[i] = 1
        
print(["First", "Second"][X[0]])