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: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0] * (K+1) for i in range(K+1)]
for i in range(min(A)):
    dp[0][i] = 1 # 負け
ans = "Second"
for i in range(K):
    for k in range(K+1):
        for x in A:
            if k + x <= K:   
                if (i == 0 or (i + 1) % 2 == 0) and dp[i][k] > 0:
                    dp[i+1][k+x] += 1
                elif (i + 1) % 2 == 1 and dp[i][k] == N:
                    dp[i+1][k+x] += 1
    if (i + 1) % 2 == 1 and dp[i+1][k] > 0:
        ans = "First"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7)
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dp=[-1]*(K+1)#0=False 1=True
def sea(i):
    if dp[i]!=-1:
        return dp[i]
    s=1
    flag=0
    for a in A:
        if i-a>=0:
            flag=1
            s*=sea(i-a)
    if flag==0:
        dp[i]=0
        return 0
    dp[i]=1-s
    return 1-s
if sea(K)==0:
    print('Second')
else:
    print('First')

Submission status: Accepted

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

dp = [False]*(K+1)
dp[0] = False
for i in range(K):
    if dp[i]:
        continue
    for s in A:
        if i+s <= K:
            dp[i+s] = True
# print(dp)
if dp[K]:
    print('First')
else:
    print('Second')

Submission status: Accepted

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

dp = [0] * (K + 1)

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

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

Submission status: Accepted

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

dp = [0] * (K + 1)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
#= input()
N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [False] * (K + 1)

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

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

Submission status: Accepted

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

def main(n,k,a):
    #Dp such that when the first takes the turn with i remaining stones,
    #0->Second, 1->First wins
    dp = [0 for i in range(k+1)]
    for i in range(1,k+1):
        for j in a:
            if j>i:
                break
            if not dp[i-j]:
                dp[i] = 1
    if dp[k]:
      print("First")
    else:
      print("Second")

if __name__=="__main__":
    n,k,a= getval()
    main(n,k,a)

Submission status: Accepted

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [False] * (k + 1)


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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp=[0 for i in range(K+1)] 

for k in range(a[0],K+1):
    for n in range(N):
        if k-a[n]>=0 and dp[k-a[n]]==0:
            dp[k]=1
    
if dp[K]==1:
    print('First')
else:
    print('Second')

Submission status: Accepted

Solution code:
temparr = input()
temparr = temparr.split()
k = int(temparr[0])
n = int(temparr[1])
arr = []
temparr = input()
temparr = temparr.split()
for i in temparr:
    arr.append(int(i))
dp = [0 for _ in range(n + 2)]
arr = sorted(arr)
dp[0] = 0 
for i in range(1, n + 2):
    for j in arr:
        if j > i :
            continue 
        if dp[i - j] == 0 :
            dp[i] = 1 
            break 
if dp[n] == 1:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = min(A)
DP = [False] * (K+1)

for i in range(m, K+1):
    for a in A:
        if i - a >= 0 and DP[i-a] == False:
            DP[i] = True
            break
if DP[-1]:
    print('First')
else:
    print('Second')

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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<=K:
            if dp[i]==0:
                dp[i+a]=1

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

Submission status: Accepted

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:
      dp[i] |= not(dp[i-a[j]])
#print(dp)
print("First" if dp[k] else "Second")

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    dp = [False]*(K+1)

    for i in range(K):
        if dp[i]:
            continue
        for a in A:
            if K < i + a:
                continue
            dp[i + a] = True

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [False]*(K+1) #if First loses, "false"
for num in range(K):
  if not(dp[num]):
    for stone in a:
      if num + stone <= K:
        dp[num+stone] = True
if dp[K]:
  print("First")
else:
  print("Second")

Submission status: Accepted

Solution code:
# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase

# If the element is already present in the list,

# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect

# If the element is already present in the list,
# the right most position where element has to be inserted is returned

# ==============================================================================================
# fast I/O region

BUFSIZE = 8192


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)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")


# ===============================================================================================
# some shortcuts

mod = 1000000007


def inp(): return sys.stdin.readline().rstrip("\r\n")  # for fast input


def out(var): sys.stdout.write(str(var))  # for fast output, always take string


def lis(): return list(map(int, inp().split()))


def stringlis(): return list(map(str, inp().split()))


def sep(): return map(int, inp().split())


def strsep(): return map(str, inp().split())


def zerolist(n): return [0] * n


def nextline(): out("\n")  # as stdout.write always print sring.


def testcase(t):
    for p in range(t):
        solve()


from collections import defaultdict, deque


class Graph(object):
    def __init__(self, dic):
        self.dict = dic
        self.vertex = set()

    def addedge(self, a, b):
        if self.dict[a] == []:
            self.vertex.add(a)
        if b != None:
            self.dict[a].append(b)

    def con_com_util(self, i, unvisited, count, comp):
        for j in self.dict[i]:
            if j in unvisited:
                unvisited.remove(j)
                comp[count].append(j)
                comp = self.con_com_util(j, unvisited, count, comp)
        return comp

    def conn_components(self):
        unvisited = self.vertex.copy()
        count = 0
        comp = defaultdict(list)
        while unvisited:
            i = unvisited.pop()
            comp[count].append(i)
            comp = self.con_com_util(i, unvisited, count, comp)
            count += 1
        return (count, comp)


def countSetBits(n):
    count = 0
    while (n):
        n &= (n - 1)
        count += 1

    return count



from sys import setrecursionlimit
setrecursionlimit(1000000)


n,k=sep()
ar=lis()
ar.sort()
dp=[0  for _ in range(k+5)]
for i in ar:
    dp[i]=1
dp[0]=0

def isvalid(i):
    if i<0:
        return False
    return True

for i in range(1,k+1):
    for j in ar:
        if isvalid(i-j):
            if dp[i-j]==0:
                dp[i]=1
                break
        else:
            break
if dp[k]==1:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
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(K+1):
    for ai in a:
        if i-ai>=0:
            dp[i] |= not dp[i-ai]

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

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc176/tasks
'''
dp[i]...次に行動するプレイヤーが勝つかどうか。石がi個あったときに。

dp[i]=True if (i-a for a \in A で一つでもFalseがあったら) else False
これは配るdpを用いて
dp[i+a] |= 1-dp[i] で書くことができる
'''

N, K = map(int, input().split())
A = list(map(int, input().split()))
dp = [0] * (K + max(A) + 1)
for i in range(K):
    for a in A:
        dp[i + a] |= 1 - dp[i]
print('First' if dp[K] else 'Second')

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
steps=list(map(int,input().split()))
dp=[True]*(k+1)
dp[0]=False
for stone in range(1,k+1):
  for s in steps:
    if s<=stone:
      dp[stone]=dp[stone]and dp[stone-s]
    else:
      break
  dp[stone]=not dp[stone]
#print(dp)
if dp[k]:
  print('First')
else:
  print('Second')

Submission status: Accepted

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 a:
        if i-j<0:continue
        if dp[i-j]==False:dp[i]=True
if dp[k]:print("First")
else:print("Second")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for i in range(K+1)]
# dp[K] := 残りKこで初めて、先手が勝つような場合 1 ,後手 が勝つような場合 0
for i in range(1, K+1):
    is_first_win = False
    for v in a:
        if i-v >= 0 and dp[i-v] == 0:
            is_first_win = True
            break
    if is_first_win:
        dp[i] = 1
if dp[K]:
    print("First")
else:
    print("Second")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

def main():
  N, K = map(int, input().split())
  arr = list(map(int, input().split()))
  dp = [False for _ in range(K + 1)]

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

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


if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[int(i) for i in input().split()]

a.sort()
dp=[0]*(K+1)

for i in range(0,a[0]):
    dp[i]='Second'

for i in range(a[0],K+1):
    for j in a:
        if i<j:
            dp[i]='Second'
            break
        if dp[i-j]=='Second':
            dp[i]='First'
            break
        if j==a[-1]:
            dp[i]='Second'

print(dp[-1])

Submission status: Accepted

Solution code:
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] | (not dp[i-A[j]])

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

Submission status: Accepted

Solution code:
def main():

    for i in range(1, K+1):
        for rm in cl:
            if rm > i:
                continue
            if dpt[i - rm] == 0:
                dpt[i] = 1
                break
        else:
            dpt[i] = 0

if __name__ == '__main__':
    N, K = map(int, input().split())
    cl = list(map(int, input().split()))
    dpt = [-1 for i in range(K+1)]
    dpt[0] = 0

    main()
    if dpt[K] == 0:
        print('Second')
    else:
        print('First')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
dp=[-1 for i in range(k+1)]
for i in range(lis[0]):
    dp[i]=0
def memo(x):
    if dp[x]!=-1:
        return dp[x]
    else:
        for i in range(n):
            if x-lis[i]<0:
                continue
            elif dp[x-lis[i]]!=-1:
                if dp[x-lis[i]]==0:
                    dp[x]=1
                    return 1
            else:
                if memo(x-lis[i])==0:
                    dp[x]=1
                    return 1
        dp[x]=0
        return 0
for i in range(k+1):
    memo(i)
#print(dp)
if dp[-1]==0:
    print("Second")
else:
    print("First")

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
a = LIST()

dp = [0]*(K+1)

for i in range(K+1):
	for x in a:
		if 0 <= i-x and dp[i-x] == 0:
			dp[i] = 1

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
dp = [0]*(K+1)
for i in range(K+1):
    for a in [x for x in A if x <= i]:
        if dp[i-a] == 0:
            dp[i] = 1
            break
    
print('First' if dp[K] else 'Second')

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
a = LIST()

dp = [0]*(K+1)

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
  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 j in range(n):
      if i-a_list[j] >= 0:
        dp[i] |= not(dp[i-a_list[j]])


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

Submission status: Accepted

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 = [1]
  for a in A:
    if i >= a:
      temp.append(dp[i-a])
  if not min(temp):
    dp[i] = 1
      
if dp[-1]:
  print("First")
else:
  print("Second")

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ls = list(map(int, input().split()))
dp = [False] * (k + 1)
for i in range(1, k + 1):
	for j in ls:
		if i - j >= 0 and not dp[i - j]:
			dp[i] = True
if dp[k]:
	print('First')
else:
	print('Second')

Submission status: Accepted

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: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)

KK = 10**5+5

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

dp = [0 for i in range(KK)]

for i in range(KK):
    for j in a:
        if i-j >= 0 and dp[i-j] == 0: dp[i] = 1

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

Submission status: Accepted

Solution code:
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

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

Submission status: Accepted

Solution code:
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
A.sort()
dp=[False]*(K+1)
dp[0]=False
for i in range(1,K+1):
    for j in range(len(A)):
        if((i-A[j])>=0):
            dp[i]= (dp[i] or (not dp[i-A[j]]))
# print(dp)
if(dp[K]==True):
    print("First")
else:
    print("Second")

Submission status: Accepted

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())

Submission status: Accepted

Solution code:
from sys import stdin
from collections import deque
n,k = map(int,stdin.readline().split())
a = list(map(int,stdin.readline().split()))
dp = [0]*(k+1)
for i in range(a[0],k+1):
    for j in a:
        if i-j >= 0 and dp[i-j] == 0:
            dp[i] = 1
            break
if dp[-1]%2:
    print('First')
else:
    print('Second')

Submission status: Accepted

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):
    ok=False
    for j in range(n):
        if i-a[j]>=0:
            if not dp[i-a[j]]:
                ok=True
    if ok:
        dp[i]=True
if dp[k]:
    print("First")
else:
    print("Second")

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
grundy=[0]*(K+1)
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
    g=0
    while g in s:g+=1
    grundy[j]=g
if grundy[K]:print("First")
else:print("Second")

Submission status: Accepted

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

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

Solution code:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
dp=[False]*(2*k+1)
for i in range(k):
  for val in arr:
    if dp[i]==False:
      dp[i+val]=True
if dp[k]==True:
  print('First')
else:
  print('Second')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

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

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


# ===CODE===

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

    dp = [False] * (k + 1)

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

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


if __name__ == '__main__':
    main()