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

Solution (Python):
import sys

import math
import collections

import bisect
import itertools
import fractions

import copy

import decimal

import queue



sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))




def main():
    n, k = ns()
    a = na()

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

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

D = [0] * (k+1)
for i in range(k+1):
    safe = 0
    for j in range(n):
        if i-A[j] >= 0 and D[i-A[j]] == 0:
            safe = 1
    D[i] = safe

print("First" if D[-1]==1 else "Second")

Solution (Python):
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))





dp = [False] * (K + 1)
for i in range(1, K + 1): 
  for j in range(len(A)): 
    if i - A[j] >= 0 and not dp[i -A[j]]:
      dp[i] = True

print(("Second","First")[dp[K]])

Solution (Python):

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [False]*(K+1)
        
    for i in range(K+1):
        for j in range(N):
            if i - A[j] >= 0:
                dp[i] |= not dp[i-A[j]]
    if dp[K]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    resolve()

Solution (Python):

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [False]*(K+1)

    for i in range(K+1):
        for j in range(N):
            if i - A[j] >= 0:
                dp[i] |= ~dp[i-A[j]]
    if dp[K]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    resolve()

Solution (Python):
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
if dp[k]==True:
  print('First')
else:
  print('Second')

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, stones = map(int, readline().split())
a = list(map(int,readline().split()))
dp = [-1]*stones
def can_or_cant(rem, chance):
    if rem == 0:
        return True
    if dp[rem] != -1:
        return dp[rem]
    den = 2 if chance == 1 else 2
    for j in range(len(a)):
        if rem - a[j] >= 0 and can_or_cant(rem-a[j], den):
            dp[rem] = False
            return False
    dp[rem] = True
    return True


res = False
for i in range(n):
    if can_or_cant(stones - a[i], 1):
        res = True
        break
print("First" if res else "Second")

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k + 1)
for i in range(k):
    if dp[i] == 0:
        for ai in a:
            if i + ai > k:
                break
            dp[i+ai] = 1
print('First' if dp[k] else 'Second')

Solution (Python):
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

dp = [False] * (K+1)
for i in range(1, K+1):
    for a in a_list:
        if i >= a:
            dp[i] = dp[i] or ~dp[i-a]
if dp[K]:
    print('First')
else:
    print('Second')

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    dp = [False] * (K+1)

    for i in range(0,K+1):
        for a in A:
            if i - a >= 0:
                
                
                dp[i] = dp[i] or (not dp[i-a])

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




if __name__ == '__main__':
    main()

Solution (Python):
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    a=tuple(map(int,sys.stdin.readline().split()))
    dp=[False for _ in range(K+1)]
    for i in range(K+1):
        for x in a:
            if i-x>=0:dp[i]=dp[i] or (not dp[i-x])
    print('First') if dp[K] is True else print('Second')
if __name__=='__main__':main()

Solution (Python):
import sys
def main():
    N,K=tuple(map(int,sys.stdin.readline().split()))
    a=tuple(map(int,sys.stdin.readline().split()))
    dp=[False for _ in range(K+1)]
    for i in range(K+1):
        for x in a:
            if i-x>=0:dp[i]=dp[i] or (not dp[i-x])
    print('First') if dp[K] is True else print('Second')
if __name__=='__main__':main()

Solution (Python):
if __name__ == "__main__":
    n,k = (int(x) for x in input().split())
    choice = [int(x) for x in input().split()]

    

    win = [False] * (k+1)
    for i in range(k+1):
        for x in choice:
            if i-x>=0 and not win[i-x]:
                win[i] = True
                break

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

Solution (Python):




import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, K, AS):
    AS.sort()
    MIN = AS[0]

    table = [0] * (K + 1)
    for i in range(MIN):
        table[i] = -1  

    for i in range(MIN, K + 1):
        for a in AS:
            if table[i - a] == -1:
                table[i] = 1
                break
        else:
            table[i] = -1

    

    if table[K] == 1:
        return "First"

    else:
        return "Second"


def main():
    
    N, K = map(int, input().split())
    AS = list(map(int, input().split()))
    print(solve(N, K, AS))



T1 = """
2 4
2 3
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    First
    """


T2 = """
2 5
2 3
"""


def test_T2():
    """
    >>> as_input(T2)
    >>> main()
    Second
    """


T3 = """
2 7
2 3
"""


def test_T3():
    """
    >>> as_input(T3)
    >>> main()
    First
    """


T4 = """
3 20
1 2 3
"""


def test_T4():
    """
    >>> as_input(T4)
    >>> main()
    Second
    """


T5 = """
3 21
1 2 3
"""


def test_T5():
    """
    >>> as_input(T5)
    >>> main()
    First
    """


T6 = """
1 100000
1
"""


def test_T6():
    """
    >>> as_input(T6)
    >>> main()
    Second
    """



def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        
        
        from my_module import solve  
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
import bisect








def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    dp = [False] * (K + 1)
    dp[0] = False  
    for i in range(K + 1):
        for j in A:
            if j <= i and dp[i-j]==False:
                dp[i] = True
                break
    if dp[K]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    main()

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
dp = [False for _ in range(K+1)]
for i in range(1, K+1):
    for j in a:
        if i - j >= 0:
            dp[i] = dp[i] or not dp[i - j]
        else:
            break
if dp[-1]:
    print("First")
else:
    print("Second")

Solution (Python):
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  


N, K = na()
a_array = na()

win = [0] * (K+1)

for i in range(a_array[0]):
    win[i] = 1

for i in range(a_array[0], K+1):
    for a in a_array:
        if i-a >= 0 and win[i-a] == 1:
            win[i] = -1
            break
    else:
        win[i] = 1



print("First" if win[-1] == -1 else "Second")

Solution (Python):










import sys

def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]

def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)


N, K = iInM()
A = iInLH()

dp = [0] * (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]] == 0:
            dp[i] = 1
            break

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

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(k+1):
  for j in range(n):
    if i-a[j]>=0:
      if dp[i-a[j]]==0:
        dp[i]=1
        break
if dp[k]:print('First')
else:print('Second')

Solution (Python):
N, K = map(int, input().split())

a = list(map(int, input().split()))
dp = [False for _ in range(K+1)]

for i in range(1, K+1):
    for j in range(N):
        if i - a[j] >= 0:
            dp[i] = dp[i] or (not dp[i - a[j]])
if dp[K]:
    print("First")
else:
    print("Second")

Solution (Python):
def solve(a,k):
    dp=[0]*(k+1)
    for i in range(k+1):
        for j in a:
            if i>=j and not dp[i-j]:
                dp[i]=1
    return 'First' if dp[-1] else 'Second'
if __name__=='__main__':
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    print(solve(a,k))

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

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

dp = [1] * (k+1)


for i in range(1, k+1):
    curr = 1
    for j in range(len(arr)):
        if arr[j] <= i:
            if dp[i-arr[j]] == 0:
                curr = 1
            else:
                curr = 0
                break
    
    dp[i] = curr



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

Solution (Python):
n, k = map(int, input().split())
lst = list(map(int, input().split()))

dp = [0] * (k+1) 

for i in range(1, k+1):
    flg = 0
    for j in lst:
        if i - j >= 0:
            if not dp[i-j]: 
                flg = 1
                break
    if flg:
        dp[i] = 1
            
if dp[k]:
    print('First')
else:
    print('Second')

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

dp = [False]*(k+1)

for i in range(k+1):
    flag = 0
    for j in a:
        if i-j < 0:
            continue
        if not dp[i-j]:
            flag = 1
            break

    if flag:
        dp[i] = True

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



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

dp = [None]*(k+1)
dp[0] = 0
for i in range(1,k+1):
    s = set(range(n+1))
    for j in range(n):
        if i-a[j]>=0:
            s.discard(dp[i-a[j]])
    dp[i] = min(s)
if dp[k]==0:
    ans = "Second"
else:
    ans = "First"
print(ans)

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))

dp = [-1] * (K+1)
dp[0] = 1
for i in range(1, K+1):
    l = [dp[i-aj] if i-aj>=0 else 0 for aj in a]
    dp[i] = 0 if 1 in l else 1
        
ans = 'First' if dp[-1] == 0 else 'Second'
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline


import heapq 
import copy
import math
import decimal











 



 

def inp():
	return(int(input()))
def inlt(): 
	return(list(map(int,input().split())))
def insr():
	s = input()
	return(list(s[:len(s) - 1]))
def insr2():
	s = input()
	return((s[:len(s) - 1]))
def invr():
	return(map(int,input().split()))
 
 

def pr_list(a):
	print(*a, sep=" ")
def main():
	
	tests = 1
	mod = 1000000007
	limit = 10**18
	ans = 0
	start = {}
	for test in range(tests):
		[n,k] = inlt()
		a = inlt()
		dp = [0 for i in range(k+1)]
		for i in range(k+1):
			flag = 0
			for j in a:
				if i-j<0:
					break
				if dp[i-j] == 0:
					flag = 1
					break
			dp[i] = flag
		if dp[k] == 1:
			print("First")
		else :
			print("Second")
				





		
		


if __name__== "__main__":
	main()

Solution (Python):
n,k=map(int,input().split())
*a,= map(int,input().split())
a=sorted(a)
limit=10**5+5
dp=[False]*limit

for i in range(limit):
    if dp[i]==False:
        for j in range(n):
            if i+a[j]<limit:
                dp[i+a[j]]=True
if dp[k]:
    print('First')
else:
    print('Second')

Solution (Python):
import sys
import math
from  collections import defaultdict





def solve(test):
	n, k = map(int, input().split())
	a = list(map(int, input().split()))


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

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

if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)

Solution (Python):
import sys
input = sys.stdin.readline
 
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
 
dp = [0 for i in range(K+1)]
for i in range(K+1):
    if not dp[i]:
        for j in range(N):
            if i + A[j] < K + 1:
                dp[i+A[j]] = 1
 
if dp[K]: print("First")
else: print("Second")

Solution (Python):
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")

Solution (Python):
n,k = map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
dp=[-1]*(k+1)

for i in range(1,k+1):
    m=1
    for j in arr:
        if(i>=j):
            m = min(dp[i-j],m)
    dp[i] = -1*m

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

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

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





dp = [0] * (k+1)

for i in a:
    dp[i] = 1



for i in range(1, k+1):
    for e in a:
        
        if i > e:
            
            if not dp[i-e]:
                dp[i] = 1

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

Solution (Python):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [0 for i in range(K+1)]
for i in range(K+1):
    if not dp[i]:
        for j in range(N):
            if i + A[j] < K + 1:
                dp[i+A[j]] = 1

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

Solution (Python):
def solve():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))

    WLs = [0] * (K+1)
    for x in range(1, K+1):
        for A in As:
            if x-A < 0:
                break
            if WLs[x-A] == 0:
                WLs[x] = 1
                break

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


solve()

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

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

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

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[False for i in range(k+1)]
for i in range(k+1):
    for j in range(n):
        if i-a[j]>=0:
            dp[i]|=(dp[i-a[j]]^(True))
if dp[k]:
    print("First")
else:
    print("Second")

Solution (Python):
N, K = map(int, input().split())
arr = list(map(int, input().split()))
dp = [False]*(K+1)
for i in range(K+1):
    for k in range(N):
        if i >= arr[k] and not dp[i-arr[k]]:
            dp[i] = True
print('First' if dp[K] else 'Second')

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

dp = [-1 for i in range(K+1)]
for i in range(min(A)):
    dp[i] = 0
for k in range(1,K+1):
    if dp[k] > 0:
        continue
    if all(dp[k-a] == 1 for a in A if k - a >= 0): 
        dp[k] = 0
    else:
        dp[k] = 1
print(['Second', 'First'][dp[-1]])

Solution (Python):
N, K = map(int, input().split())
stone = list(map(int, input().split()))
dp = [False]*(K+1)
for i in range(1,K+1):
    for k in range(N):
        if i >= stone[k]:
            if not dp[i-stone[k]]:
                dp[i] = True
print('First' if dp[K] else 'Second')

Solution (Python):
def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    dp = [0 for _ in range(K + 1)]  
    for n in range(1, K + 1):
        win = 0
        for a in A:
            if n - a >= 0 and dp[n - a] == 0:
                win = 1
                break
        dp[n] = win
    print('First' if dp[K] == 1 else 'Second')


if __name__ == '__main__':
    main()

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

Solution (Python):
def is_win(n,k):
	dp=[False]*(k+1)
	for i in range(k+1):
		for j in range(n):
			if i-arr[j]>=0 and dp[i-arr[j]]==False:
				dp[i]=True
				break

	return dp[k]
	


n,k=map(int,input().split())
arr=list(map(int,input().split()))
res=is_win(n,k)
print('First' if res else 'Second')

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  dp=[0]*100100

  for i in range(k):
    for x in l:
      y=dp[i]

      if y==0 and i+x<100100:
        dp[i+x]=1

  if dp[k]==1:
    return 'First'
  return 'Second'


print(main())

Solution (Python):


n, k = [int(x) for x in input().split()]

arr = [int(x) for x in input().split()]

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

for i in range(k+1):
    for x in arr:
        if i-x >= 0 and not dp[i-x]:
            dp[i] = True

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

Solution (Python):

l=input().split()
n=int(l[0])
k=int(l[1])
l=input().split()
li=[int(i) for i in l]
hashi=dict()
for i in li:
	hashi[i]=1
m=min(li)
dp=[0 for i in range(k+1)]
dp[0]=2
for i in range(1,k+1):
	if(i<m):
		dp[i]=2
	done=0
	for j in hashi:
		if(i>=j and dp[i-j]==2):
			done=1
			break
	dp[i]=2-done
if(dp[k]==1):
	print("First")
else:
	print("Second")

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[K] - answers if Taro wins with K stones

    OPT[a[i]] = True 1 <= k <= N

    5
    2 3
    
    t t j j j
    t t t j j

    OPT(K) - True, if Taro loses the game with K stones
    OPT(K) = all(not OPT(K-a[i])) 1 <= i <= N
    OPT(0) = True
    """
    N, K = read_ints()
    a = read_ints()
    OPT = [False]*(K+1)
    OPT[0] = True
    for k in range(1, K+1):
        OPT[k] = all(not OPT[k-a[i]] for i in range(N) if k-a[i] >= 0)
    if OPT[K]:
        return 'Second'
    return 'First'


if __name__ == '__main__':
    print(solve())

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

lst=[0]*(k+1)







for i in range(k+1):
    flag=1
    for j in range(n):
        if i-a[j]>=0:
            flag=min(flag,lst[i-a[j]])

    if flag==0:
        lst[i]=1
    else:
        lst[i]=0

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    dp = [False] * (K+1)
    for i in range(K+1):
        for hop in a:
            if i - hop >= 0:
                if dp[i - hop] is False:
                    dp[i] = True
                    break
    if dp[-1]:
        print("First")
    else:
        print("Second")


if __name__ == "__main__":
    main()

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

dp = [False]*(2*K + 1)
for i in range(K):
    if not dp[i]:
        for a in A:
            dp[i+a] = True
if dp[K]:
    print("First")
else:
    print("Second")

Solution (Python):



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

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


dp = [0]*(k + 1)

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


if dp[i] == 1:
    print("First")

else:
    print("Second")

Solution (Python):
import sys
input=sys.stdin.readline


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 and dp[i-a[j]]==False:
			dp[i]=True;break
if dp[-1]:print("First")
else:print("Second")

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

dp = [1] * (k + 1)
player = ["First", "Second"]

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

print(player[dp[k]])

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  dp=[0]*100100
  l=LI()

  for i in range(k):
    for x in l:
      if i+x<=k:
        if dp[i+x]==0 and dp[i]==0:
          dp[i+x]=1

  
  return 'First' if dp[k] else 'Second'


print(main())

Solution (Python):
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
dp=[[-1,-1] for i in range(k+1)]
for i in range(1,k+1):
    for j in a:
        if i>=j:
            if dp[i-j][0]==-1 and dp[i-j][1]==-1:
                dp[i][0]=1
            elif dp[i-j][1]==1:
                dp[i][0]=1
    if dp[i][0]==-1:
        dp[i][1]=1
if dp[k][0]==1:
    print('First')
else:
    print('Second')

Solution (Python):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [0]*(k+1)
for i in range(k+1):
  for a in A:
    if i-a >= 0 and not dp[i-a]:
      dp[i] = 1
      break
result = dp[k]
if result:
  print("First")
else:
  print("Second")

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [-1]*(k+1)
def dfs(k):
  if dp[k] != -1:
    return dp[k]
  for a in A:
    if k-a >= 0 and dfs(k-a) == 0:
      dp[k] = 1
      return 1
  dp[k] = 0
  return 0
result = dfs(k)
if result:
  print("First")
else:
  print("Second")

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

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]

def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]

def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N,K = MI()
A = LI()
dp = [True]*(K+1)
for i in range(min(A),K+1):
    ret = True
    for a in A:
        if i-a>=0:
            if dp[i-a]==True:
                ret = False
                break
    dp[i] = ret

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

Solution (Python):
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [0 for _ in range(k + 1)]
	for i in range(1, k + 1):
		for num in A:
			if i - num < 0:
				continue
			if dp[i]: 
				break
			if not dp[i-num]: 
				dp[i] = 1
	print("First" if dp[-1] else "Second")
	stdout.close()

if __name__ == "__main__":
	main()

Solution (Python):
N,K=map(int,input().split())
a=list(map(int,input().split()))
ans=[0 for e in range(K+1)]
for i in range(a[0]):
 ans[i]=1
for m in range(a[0],K+1):
 t=0
 for j in a:
  if j>m:
   continue
  else:
   if ans[m-j]==1:
    t+=1
 if t==0:
  ans[m]=1
 else:
  ans[m]=0
if ans[K]==0:
 print("First")
else:
 print("Second")

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

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [False]*(K+1)

for i in range(K+1):
    for ai in a:
        if i-ai>=0:
            dp[i] |= not dp[i-ai]

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[False]*(k+1) 
    for i in range(min(A),k+1):
        for a in A:
            if i-a>=0 and not dp[i-a]:
                dp[i]=True
                break
        else:
            dp[i]=False
    if dp[k]:
        print("First")
    else:
        print("Second")

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    dp=[0]*(k+1) 
    for i in range(min(A),k+1):
        for a in A:
            if i-a>=0 and dp[i-a]==0:
                dp[i]=1
                break
        else:
            dp[i]=0
    if dp[k]==0:
        print("Second")
    else:
        print("First")

if __name__=='__main__':
    main()

Solution (Python):
N, K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
dp = ['Second' for _ in range(K + 1)]
i = 0
for i in range(min(a), K + 1):
  for j in range(N):
    if i - a[j] >= 0:
      if dp[i-a[j]] == 'Second':
        dp[i] = 'First'
print(dp[K])