CodeEff/ECCO huggingface dataset:
# Original solution
import sys

def exhaustiveSearch(A, m, i):
    if A[i] == m:
        return True
    elif i == len(A) - 1 or m < 0:
        return False

    return exhaustiveSearch(A, m, i + 1) or exhaustiveSearch(A, m - A[i], i + 1)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = list(map(int, lines[1].split()))
    M = list(map(int, lines[3].split()))

    for m in M:
        if exhaustiveSearch(A, m, 0):
            print("yes")
        else:
            print("no")

# Optimized solution
import sys

def exhaustiveSearch(A, m, i, s):
    if A[i] == m:
        return True
    elif i == len(A) - 1 or m < 0 or m > s:
        return False

    return exhaustiveSearch(A, m, i + 1, s) or exhaustiveSearch(A, m - A[i], i + 1, s)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = list(map(int, lines[1].split()))
    M = list(map(int, lines[3].split()))
    s = sum(A)

    for m in M:
        if exhaustiveSearch(A, m, 0, s):
            print("yes")
        else:
            print("no")
# Original solution
n= int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
Mi = list(map(int, input().split()))

def solve(i,m):
 if m == 0:
  return True
 if i >= n:
  return False
 res = solve(i+1, m) or solve(i + 1, m - A[i])
 return res

for m in Mi:
 if solve(0, m):
  print("yes")
 else:
  print("no")

# Optimized solution
n= int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
Mi = list(map(int, input().split()))
PS={}
def solve(i,m):
 if m == 0:
  return True
 if (i,m) in PS:
  return PS[(i,m)]
 if i >= n:
  return False
 res = solve(i+1, m) or solve(i + 1, m - A[i])
 PS[(i,m)] = res
 return res

for m in Mi:
 if solve(0, m):
  print("yes")
 else:
  print("no")
# Original solution
isExist = [False]*2001 
n = int( eval(input()) )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in A:
	for j in range( 2000-i, 0, -1 ):
		if isExist[j]:
			isExist[ i+j ] = True
	isExist[i] = True

q = int( eval(input()) )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

# Optimized solution
isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in A:
	for j in range( 2000-i, 0, -1 ):
		if isExist[j]:
			isExist[ i+j ] = True
	isExist[i] = True

q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
mi = list(map(int, input().split()))

def solve(i, m):
    if (m == 0):
        return True
    if (i >= n):
        return False
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res

for j in mi:
    if solve(0, j):
        print("yes")
    else:
        print("no")

# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
mi = list(map(int, input().split()))
t = {}

def solve(i, m):
    if (m == 0):
        return True
    if (i >= n):
        return False
    if (i,m) in t:
        return t[(i,m)]
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    t[(i,m)] = res
    return res

for m in mi:
    if solve(0, m):
        print("yes")
    else:
        print("no")
# Original solution
def solve(Mi,i):
	if Mi == 0: return True
	if i < n and Mi > 0:
		r1 = solve(Mi-A[i],i+1)
		r2 = solve(Mi,i+1)
		if r1: return r1
		if r2: return r2
n = eval(input())
A = list(map(int,input().split()))
q = eval(input())
M = list(map(int,input().split()))
for Mi in M:
	print("yes" if solve(Mi,0) else "no")

# Optimized solution
def solve(Mi,i):
	if Mi == 0: return True
	if i < n and min(A[i:]) <= Mi <= sum(A[i:]):
		r1 = solve(Mi-A[i],i+1)
		r2 = solve(Mi,i+1)
		if r1: return r1
		if r2: return r2
n = eval(input())
A = list(map(int,input().split()))
q = eval(input())
M = list(map(int,input().split()))
for Mi in M:
	print("yes" if solve(Mi,0) else "no")
# Original solution
n1 = eval(input())
A = list(map(int, input().split()))

n2 = eval(input())
q = list(map(int, input().split()))

list = set()

def solve(i,m):
 if m == 0:
  return True
 if i >= n1:
  return False
 res = solve(i+1,m) or solve(i+1,m-A[i])
 return res

for m in q:
 if solve(0,m):
  print("yes")
 else:
  print("no")

# Optimized solution
n1 = eval(input())
A = list(map(int, input().split()))

n2 = eval(input())
q = list(map(int, input().split()))

list = set()

def solve(i,m):
 if m == 0:
  return True
 if i >= n1 or m > sum(A):
  return False
 res = solve(i+1,m) or solve(i+1,m-A[i])
 return res

for m in q:
 if solve(0,m):
  print("yes")
 else:
  print("no")
# Original solution

def solve(arr, m):
	dict = {}
	return solve_rec(0, arr, m, dict)

def solve_rec(i, arr, m, dict):
	key = str(i) + '-' + str(m)
	res = False
	if key in dict:
		res = dict[key]
	elif m == 0:
		res = True
	elif i >= len(arr):
		res = False
	else:
		res1 = solve_rec(i + 1, arr, m, dict)
		res2 = solve_rec(i + 1, arr, m - arr[i], dict)
		res = res1 or res2	
	dict[key] = res
	return res

n = int(eval(input()))
arr = list(map(int, input().split()))
q = int(eval(input()))
targets = list(map(int, input().split()))

for i in range(q):
	res = solve(arr, targets[i])
	if res == True:
		print('yes')
	else:
		print('no')



# Optimized solution

def solve(a, m):
	dict = {}
	return solve_(a, 0, m, dict)

def solve_(a, i, m, dict):
	res = False
	key = str(i) + '-' + str(m)
	if key in dict:
		res = dict[key]
	elif m == 0:
		res = True
	elif i >= len(a):
		res = False
	else:
		res1 = solve_(a, i + 1, m, dict)
		res2 = solve_(a, i + 1, m - a[i], dict)
		res = res1 or res2
	dict[key] = res
	return res

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
for i in range(q):
	if solve(a, m[i]):
		print('yes')
	else:
		print('no')
# Original solution
def subset_sum(s, a):
	dict = {}
	return subset_rec(0, s, a, dict)
	
def subset_rec(i, s, a, dict):
	key = str(i) + '-' + str(s)
	ret = False
	if key in dict:
		ret = dict[key]
	elif s == 0:
		ret = True
	elif i >= len(a):
		ret =  False
	else:
		ret = subset_rec(i+1, s-a[i], a, dict) or subset_rec(i+1, s, a, dict)
	dict[key] = ret
	return ret	

n = int(eval(input()))
a = list(map(int, input().split()))
p = int(eval(input()))
q = list(map(int, input().split()))
for i in range(p):
	if subset_sum(q[i], a):
		print('yes')
	else:
		print('no')



# Optimized solution
def subset_sum(s, a):
	dict = {}
	return subset_rec(0, s, a, dict)
	
def subset_rec(i, s, a, dict):
	key = str(i) + '-' + str(s)
	if key in dict:
		ret = dict[key]
	elif s == 0:
		ret = True
	elif i >= len(a):
		ret =  False
	else:
		ret = subset_rec(i+1, s-a[i], a, dict) or subset_rec(i+1, s, a, dict)
	dict[key] = ret
	return ret

n = int(eval(input()))
a = list(map(int, input().split()))
p = int(eval(input()))
q = list(map(int, input().split()))
for i in range(p):
	if subset_sum(q[i], a):
		print('yes')
	else:
		print('no')
# Original solution
def subset_sum(s, a):
	dict = {}
	return subset_rec(0, s, a, dict)
	
def subset_rec(i, s, a, dict):
	key = str(i) + '-' + str(s)
	if key in dict:
		ret = dict[key]
	elif s == 0:
		ret = True
	elif i >= len(a):
		ret =  False
	else:
		ret = subset_rec(i+1, s-a[i], a, dict) or subset_rec(i+1, s, a, dict)
	dict[key] = ret
	return ret

n = int(eval(input()))
a = list(map(int, input().split()))
p = int(eval(input()))
q = list(map(int, input().split()))
for i in range(p):
	if subset_sum(q[i], a):
		print('yes')
	else:
		print('no')



# Optimized solution
def subset_sum(s, a):
	n = len(a)
	dp = [[False for x in range(s+1)] for x in range(n+1)]
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v == j:
				dp[i+1][j] = True
			elif v > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = dp[i][j] or dp[i][j-v]
	return dp[n][s]

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(m[i], a) == True:
		print('yes')
	else:
		print('no')
# Original solution
def subset_sum(n, s, a):
	dp = [[0 for x in range(s+1)] for x in range(n+1)]
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v==j or (v<j and dp[i][j-v]>0):
				dp[i+1][j] = dp[i][j] + 1
			else:
				dp[i+1][j] = dp[i][j]
	return dp[n][s] > 0

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(n, m[i], a) == True:
		print('yes')
	else:
		print('no')



# Optimized solution
def subset_sum(n, s, a):
	dp = [[0 for x in range(s+1)] for x in range(n+1)]
	dp[0][0]=1
	for i in range(n):
		v = a[i]
		for j in range(s+1):
			if v > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = dp[i][j]+dp[i][j-v]
	return dp[n][s] > 0

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
for i in range(q):
	if subset_sum(n, m[i], a) == True:
		print('yes')
	else:
		print('no')
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
M = list(map(int, input().split()))
def rec(i, m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = rec(i + 1, m)
    if m - A[i] >= 0:
        res |= rec(i + 1, m - A[i])
    return res
for m in M:
    if rec(0, m):
        print('yes')
    else:
        print('no')


# Optimized solution
n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
M = list(map(int, input().split()))
bits = 1
for a in A:
    bits |= bits << a
for m in M:
    print(('yes' if (bits >> m) & 1 else 'no'))
# Original solution
n = eval(input())
A = list(map(int, input().split()))
q = eval(input())
M = list(map(int, input().split()))

def solve(i,m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) or solve(i+1, m - A[i])
  return res

for m in M:
    if solve(0, m):
      print('yes')
    else:
      print('no')

# Optimized solution
n = eval(input())
A = list(map(int, input().split()))
q = eval(input())
M = list(map(int, input().split()))

min = min(A)
sum = sum(A)

def solve(i,m):
  if sum < m:
    return False
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) or solve(i+1, m - A[i])
  return res
 
for m in M:
    if solve(0, m):
      print('yes')
    else:
      print('no')
# Original solution
from itertools import combinations

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

s = set()
for i in range(1, n):
    for j in combinations(a, i):
        s.add(sum(j))
for ans in m:
    print(('yes' if ans in s else 'no'))

# Optimized solution
from itertools import combinations

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

s = set()
for i in range(1, n + 1):
    for j in combinations(a, i):
        s.add(sum(j))
for ans in m:
    print(('yes' if ans in s else 'no'))
# Original solution
from collections import deque

class MyClass():    
    def load(self):
        self.n = eval(input())
        self.A = list(map(int,input().split()))
        self.q = eval(input())
        self.M = list(map(int,input().split()))

    def main(self):
        self.load()
        W = list(map(self.solve,self.M))
        for w in W:
            print(w)

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,list(qA))
            if w:
                break
            qA.popleft()
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        else:
            if len(A) == 1:
                r2 = False
            else:
                r2 = self.rec(m_new,A[1:])
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

# Optimized solution
from collections import deque

class MyClass():    
    def load(self):
        self.n = eval(input())
        self.A = list(map(int,input().split()))
        self.q = eval(input())
        self.M = list(map(int,input().split()))

    def main(self):
        self.load()
        W = list(map(self.solve,self.M))
        for w in W:
            print(w)

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,list(qA))
            if w:
                break
            qA.popleft()
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 0:
            return False
        else:
            r1 = self.rec(m,A[1:])
            m_new = m - A[0]
            if m_new < 0:
                r2 = False
            elif m_new == 0:
                r2 = True
            else:
                r2 = self.rec(m_new,A[1:])
            
            if r1 or r2:
                return True
            else:
                return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()
# Original solution
class MyClass():
    def main(self):
        self.n = eval(input())
        self.A = list(map(int,input().split()))
        self.q = eval(input())
        self.M = list(map(int,input().split()))
        
        W = list(map(self.solve,self.M))
        for w in W:
            print(w)

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])
        
        m_new = m - A[0]
        if m_new < 0:
            r2 = False
        elif m_new == 0:
            r2 = True
        elif len(A) == 1 or m_new < min(A[1:]):
            r2 = False
        else:
            r2 = self.rec(m_new,A[1:])
        
        if r1 or r2:
            return True
        else:
            return False
    
if __name__ == "__main__":
    MC = MyClass()
    MC.main()

# Optimized solution
class MyClass():
    def main(self):
        self.n = eval(input())
        self.A = list(map(int,input().split()))
        self.q = eval(input())
        self.M = list(map(int,input().split()))
        
        W = list(map(self.solve,self.M))
        for w in W:
            print(w)

    def solve(self,m):
        w = self.rec(m,self.A)
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        if len(A) == 1:
            r1 = False
        else:
            r1 = self.rec(m,A[1:])

        m_new = m - A[0]
        if m_new == 0:
            r2 = True
        elif len(A) > 1 and min(A[1:]) <= m_new <= sum(A[1:]):
            r2 = self.rec(m_new,A[1:])
        else:
            r2 = False

        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()
# Original solution
from itertools import combinations

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

cache = {}


def sum_a(tmp, t):
    global a, cache
    if t in cache:
        return tmp + cache[t]
    elif len(t) == 1:
        return tmp + a[t[0]]
    else:
        cache[t] = result = sum_a(tmp + a[t[0]], t[1:])
        return result


l = list(sum_a(0, t) for i in range(n) for t in combinations(list(range(n)), i + 1))

for m in ms:
    print(('yes' if m in l else 'no'))

# Optimized solution
from itertools import combinations

n, a, q, ms, cache = int(eval(input())), list(map(int, input().split())), eval(input()), list(map(int, input().split())), {}


def sum_a(tmp, t):
    global a, cache
    if t in cache:
        return tmp + cache[t]
    elif len(t) == 1:
        return tmp + a[t[0]]
    else:
        cache[t] = result = sum_a(tmp + a[t[0]], t[1:])
        return result


l = set(sum_a(0, t) for i in range(n) for t in combinations(list(range(n)), i + 1))

for m in ms:
    print(('yes' if m in l else 'no'))
# Original solution
from itertools import combinations

n, a, q, ms, cache = int(eval(input())), list(map(int, input().split())), eval(input()), list(map(int, input().split())), {}

l = set(sum(t) for i in range(n) for t in combinations(a, i + 1))

for m in ms:
    print(('yes' if m in l else 'no'))

# Optimized solution
from itertools import combinations

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

l = set(sum(t) for i in range(n) for t in combinations(a, i + 1))

for m in map(int, input().split()):
    print(('yes' if m in l else 'no'))
# Original solution
a_len = int(eval(input()))
a_ar = sorted([int(n) for n in input().split(" ")])
b_len = int(eval(input()))
b_ar = [int(n) for n in input().split(" ")]
dp = [0 for n in range(2001)]
for a in a_ar:
    new_dp = dp[:]
    new_dp[a] = 1
    for i,d in enumerate(dp):
        if d and i + a <= 2000:
            new_dp[i + a] = 1
        elif i + a > 2000:
            break
    dp = new_dp
for b in b_ar:
    if dp[b]:
        print("yes")
    else:
        print("no")

# Optimized solution
a_len = int(eval(input()))
a_ar = sorted([int(n) for n in input().split(" ")])
b_len = int(eval(input()))
b_ar = [int(n) for n in input().split(" ")]
max_b = max(b_ar)
dp = [0 for n in range(max_b + 1)]
for a in a_ar:
    new_dp = dp[:]
    new_dp[a] = 1
    for i,d in enumerate(dp):
        if d and i + a <= max_b:
            new_dp[i + a] = 1
    dp = new_dp
for b in b_ar:
    if dp[b]:
        print("yes")
    else:
        print("no")
# Original solution
eval(input())
A = list(map(int,input().split()))
eval(input())
M = list(map(int,input().split()))

def solve(i,m):
    a = 0
    if a ==m:
        return True
    if i >= len(A):
        return False
    
    res = solve(i+1,m) or solve(i+1,m-A[i])
    return res 

for k in M:
    print(("yes" if solve(0,k) else "no"))
        

# Optimized solution
eval(input())
A = list(map(int,input().split()))
eval(input())
M = list(map(int,input().split()))

d = {}
def solve(i,s):
    if i == len(A):
        d[s] = 0
        return s
        
    solve(i+1,s)
    solve(i+1,s+A[i])
    return 1

solve(0,0)
for a in M:
    if a in d:
        print("yes")
    else:
        print("no")
# Original solution
n = int(input())
A = list(map(int, input().strip().split(' ')))
q = int(input())
M = list(map(int, input().strip().split(' ')))

memo = []
for i in range(len(A)+1):
    memo.append([None]*2000)

def solve(i,m):
    if memo[i][m] != None: return memo[i][m]
    if m == 0:
        memo[i][m] = True
        return True
    elif i >= n:
        memo[i][m] = False
        return False
    else:
        return solve(i+1,m) | solve(i+1,m-A[i])

for m in M:
    if solve(0,m): print("yes")
    else: print("no")

# Optimized solution
n = int(input())
A = list(map(int, input().strip().split(' ')))
q = int(input())
M = list(map(int, input().strip().split(' ')))

memo = []
for i in range(len(A)+1):
    memo.append([None]*2000)

def solve(i,m):
    if memo[i][m] != None: return memo[i][m]
    if m == 0:
        memo[i][m] = True
        return True
    elif i >= n:
        memo[i][m] = False
        return False
    else:
        ret = solve(i+1,m) | solve(i+1,m-A[i])
        memo[i][m] = ret
        return ret

for m in M:
    if solve(0,m): print("yes")
    else: print("no")
# Original solution
# -*- coding:utf-8 -*-
import sys


def exhaustive(n, target, lst):
    if n == target:
        return True
    if n > target or lst == []:
        return False
    else:
        for i, val in enumerate(lst, 1):
            if exhaustive(n + val, target, lst[i:]):
                return True
    return False


def main(data, targets):
    for target in targets:
        if exhaustive(0, target, data):
            print("yes")
        else:
            print("no")


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    data = [int(n) for n in lst[1]]
    targets = [int(n) for n in lst[3]]
    main(data, targets)

# Optimized solution
# -*- coding:utf-8 -*-
import sys


def exhaustive(lst, size):
    result = []
    for i in range(0, 1 << size):
        total = 0
        for j in range(0, size):
            if (i & 0x01) == 1:
                total += lst[j]
            i = i >> 1
        result.append(total)
    return result


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    n, data, m, targets = [[int(n) for n in inner_lst] for inner_lst in lst]
    result = exhaustive(data, int(n[0]))
    print(("\n".join(["yes" if x in result else "no" for x in targets])))
# Original solution
n = eval(input())
  
A = list(map(int, input().split()))
   
q = eval(input())
   
M = list(map(int, input().split()))
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print("yes")
  else:
    print("no")

# Optimized solution
n = eval(input())

A = list(map(int, input().split()))
   
q = eval(input())
   
M = list(map(int, input().split()))
  
def solve(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  res = solve(i+1, m) or solve(i+1, m - A[i])
  return res
  
  
for m in M:
  if solve(0,m):
    print("yes")
  else:
    print("no")
# Original solution
s=[len(c) for c in list(input().split("T"))]
x,y=list(map(int,input().split()))
XX=s[::2]
YY=s[1::2]
X=[XX[0]]
Y=[0]
XXX=[]
for i in range(1,len(XX)):
    for j in X:
        XXX.append(j+XX[i])
        XXX.append(j-XX[i])
    X=XXX
    XXX=[]

YYY=[]
for i in range(len(YY)):
    for j in Y:
        YYY.append(j+YY[i])
        YYY.append(j-YY[i])
    Y=YYY
    YYY=[]

if x in X and y in Y:
    print("Yes")
else:
    print("No")

# Optimized solution
s=[len(c) for c in list(input().split("T"))]
x,y=list(map(int,input().split()))
XX=s[::2]
YY=s[1::2]
X=set([XX[0]])
Y=set([0])
XXX=[]
for i in range(1,len(XX)):
    for j in X:
        XXX.append(j+XX[i])
        XXX.append(j-XX[i])
    X=set(XXX)
    XXX=[]

YYY=[]
for i in range(len(YY)):
    for j in Y:
        YYY.append(j+YY[i])
        YYY.append(j-YY[i])
    Y=set(YYY)
    YYY=[]

if x in X and y in Y:
    print("Yes")
else:
    print("No")