Problem:


Exhaustive Search

Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.

You are given the sequence A and q questions where each question contains Mi.

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.

Output

For each question Mi, print yes or no.

Constraints

n ≤ 20

 q ≤ 200 

1 ≤ elements in A ≤ 2000

1 ≤ Mi ≤ 2000

Sample Input 1

5
1 5 7 10 21
8
2 4 17 8 22 21 100 35

Sample Output 1

no
no
yes
yes
yes
yes
no
no

Notes

You can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:

solve(0, M) 

solve(1, M-{sum created from elements before 1st element}) 

solve(2, M-{sum created from elements before 2nd element}) 

...

The recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.

For example, the following figure shows that 8 can be made by A[0] + A[2].

Template in C
-->



Sample input:
5
1 5 7 10 21
8
2 4 17 8 22 21 100 35


Sample output:
no
no
yes
yes
yes
yes
no
no

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_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"

Submission status: Runtime Error

Solution code:
def check(m,g,A,n):
    
    for i in range(n):
        gg = g + A[n-i-1]
        if m == gg:
            return True
        elif n == 0 or m < gg:
            continue
        if check(m,gg,A,n-i-1) == True:
            return True
    return False
        

n=int(input())
A=list(map(int,str.split(input())))
q = int(input())
m=list(map(int,str.split(input())))

mini = min(A)
nor = sum(A)

for mi in m:
    if mi < mini or mi > nor:
        print(no)
    if check(mi,0,A,n):
        print("yes")
    else:
        print("no")

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res
 
 for j in range(0, q-1):
  if m == solve(i + 1, m) || solve(i + 1, m - A[i]):
   print "yes"
  else:
   print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res
 
 for j in range(0, q-1):
  if m == solve(j, m(j)):
   print "yes"
  else:
   print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res
 
for j in range(0, q-1):
 if m == solve(j, m(j)):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

 def solve(i, m):
  if i == m:
   return true
  if i > n:
   return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
   return res
 
 for j in range(0, q-1):
  if m == solve(j, m(j)):
   print "yes"
  else:
   print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

 def solve(i, m):
  if i == m:
   return true
  if i > n:
   return false
  res = solve(i + 1, m) || solve(i + 1, m - A(i))
   return res
 
 for j in range(0, q):
  if m == solve(j, m(j)):
   print "yes"
  else:
   print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A(i))
  return res
 
for j in range(0, q-1):
 if m == solve(0, m(j)):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A(i))
 return res
 
for j in range(0, q-1):
 if m == solve(j, m(j)):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) or solve(i + 1, m - A(i))
 return res
 
for j in range(0, q):
 if m == solve(0, m(j)):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
??
def solve(i, m):
??if m == 0:
????return true
??if i >= n and m > 0:
????return false
??res = solve(i + 1, m) or solve(i + 1, m - A(i))
??return res
????
for j in range(0, q):
??if m == solve(0, m(j)):
????print "yes"
??else:
????print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

def solve(i, m):
 if m == 0:
  return true
 if i >= n and m > 0:
  return false
 res = solve(i + 1, m) or solve(i + 1, m - A(i))
 return res

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

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_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 range(0, q):
 if solve(0, m(j)):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

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

for j in range(0, q):
 if m == solve(0, m[j]):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())

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

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

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())

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

for j in range(0, q-1):
 if solve(0, m[j]):
  print "yes"
 else:
  print "no"

Submission status: Runtime Error

Solution code:

n = int(raw_input())
A = map(int, raw_input().split())
sorted(A)

q = int(raw_input())
M = map(int, raw_input().split())
sorted(M)

result = []
for i in range(q):
    result.append('no ')

for i in range(n-1):
    sum_n = A[i]
    M_clone = M[:]
    flag = False
    for j in range(n-1-i):
        if flag:
            break
        sum_n += A[i+1+j]
        for k in range(len(M)):
            if M_clone[k] == sum_n:
                result[k] = 'yes '
                M.pop(k)
                flag = True
                break
            elif M_clone[k] < sum_n:
                M_clone.pop(k)

for i in range(q):
    print result[i]

Submission status: Runtime Error

Solution code:

n = int(raw_input())
A = map(int, raw_input().split())
A.sort()

q = int(raw_input())
M = map(int, raw_input().split())
M.sort()

result = []
for i in range(q):
    result.append('no')

for i in range(n-1):
    sum_n = A[i]
    M_clone = M[:]
    flag = False
    for j in range(n-1-i):
        if flag:
            break
        sum_n = sum_n + A[i+1+j]
        for k in range(len(M)):
            if M_clone[k] == sum_n:
                result[k] = 'yes'
                M.pop(k)
                flag = True
                break
            elif M_clone[k] < sum_n:
                M_clone.pop(k)

for i in range(q):
    print result[i]

Submission status: Runtime Error

Solution code:

n = int(raw_input())
A = map(int, raw_input().split())
A.sort()

q = int(raw_input())
M = map(int, raw_input().split())
M.sort()

result = []
for i in range(q):
    result.append('no')

for i in range(n-1):
    sum_n = A[i]
    M_clone = M[:]
    flag = False
    for j in range(n-1-i):
        if flag:
            break
        sum_n = sum_n + A[i+1+j]
        for k in range(len(M)):
            if M_clone[k] == sum_n:
                result[k] = 'yes'
                M.pop(k)
                flag = True
                break
            elif M_clone[k] < sum_n:
                M_clone.pop(k)

for i in result:
    print(i)

Submission status: Runtime Error

Solution code:
n = input()
A = map(int,raw_input().split())
q = input()
M = map(int,raw_input().split())

def tansaku(Mi,i):
    if Mi == 0: return True
    if i < n and min(A[i:] <= Mi <= sum(A[i:]):
        r1 = tansaku(Mi-A[i],i+1) #Mi-A[i] == 0 ????????°???True
        if r1: return r1
        r2 = tansaku(Mi,i+1)
        if r2: return r2
        
for Mi in M:
    print "yes" if solve(Mi,0) else "no"

Submission status: Runtime Error

Solution code:

n = int(raw_input())
A = map(int, raw_input().split())

q = int(raw_input())
M = map(int, raw_input().split())

result = []
for i in range(q):
    result.append('no')

for i in range(n-1):
    sum_n = A[i]
    for j in range(n-1-i):
        ad = A[i+1+j]
        for k in range(n-2-j):
            sum_n = sum_n + ad
            ad = ad + A[i+j+2+k]
            if M[k] == sum_n:
                result[k] = 'yes'

for i in result:
    print(i)

Submission status: Runtime Error

Solution code:
for i in range(n):
    sum_n = A[i]
    for j in range(q):
        if M[j] == sum_n:
            result[j] = 'yes'
    for j in range(n-1-i):
        sum_n = A[i]
        ad = A[i+j+1]
        sum_n = sum_n + ad
        for k in range(q):
            if M[k] == sum_n:
                result[k] = 'yes'
        for k in range(n-2-i-j):
            ad = ad + A[i+j+2+k]
            sum_n = sum_n + ad
            for l in range(q):
                if M[l] == sum_n:
                    result[l] = 'yes'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m]==0 or dp[i][m]==1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m]==1
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m]!=-1
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] is not -1
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [][]

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = []

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[]]

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[]*p]*n

for i in range(n):
  for m in range(p):
    dp[i][m] == -1

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = = [[-1 for col in range(p)] for row in range(n)]

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[-1 for col in range(p)] for row in range(n)]

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[-1 for col in range(2000)] for row in range(n)]

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]

  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0

  return dp[i][m]



n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())

dp = [[-1 for col in range(n)] for row in range(2000)]

for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
m = map(int,raw_input().split())
  
def solve(i,m):
  if m == 0:
    return 1
  if i >= n or m - sum(A) > 0:
    return 0
  res = solve(i+1,m) or solve(i+1,m-A[i])
    return res
  
for j in range(q):
  if solve(0,m[j]):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
m = map(int,raw_input().split())
  
def solve(i,m):
  if m == 0:
    return 1
  if i >= n or m - sum(A) > 0:
    return 0
  res = solve(i+1,m) or solve(i+1,m-A[i])
    return res
  
for j in range(q):
  if solve(0,m[j]):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int,raw_input().split())
q = int(raw_input())
m = map(int,raw_input().split())

def solve(i,m):
     if m == 0:
        return 1
     if i >= n or m - sum(A) > 0:
        return 0
     res = solve(i+1,m) or solve(i+1,m-A[i])
        return res
  
for j in range(q):
     if solve(0,m[j]):
        print "yes"
     else:
        print "no"

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
m = map(int, raw_input().split())
 
def solve(i, m):
    if m == 0:
        return 1
    if i > n or m > sum(A):
        return 0
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res
         
for j in range(0, q):
    if solve(0, m[j]):
        print "yes"
    else:
        print "no"

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !



for i in xrange(50):
    for j in xrange(50):
        dp[i][j] = 0
        
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp =[[-1]*1000]*1000

for i in xrange(0,q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"

Submission status: Runtime Error

Solution code:

def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]
 
  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0
 
  return dp[i][m]
 
 
 
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
 
dp = [[-1 for i in range(max(m)+1)] for j in range(n+1)]
 
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:

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

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp = [[-1 for i in xrange(max(p)+1)] for j in xrange(n+1)]
for i in xrange(q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
  
def solve(i,m):
  if m == 0:
    return True
  if i >= n or m - sum(A) > 0:
    return False
  res = solve(i+1,m) or solve(i+1, m-A[i]
  return res

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

Submission status: Runtime Error

Solution code:
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
  
def solve(i,m):
  if m == 0:
    return True
  if i >= n or m - sum(A) > 0:
    return False
  res = solve(i+1,m) or solve(i+1, m-A[i]
  return res

for j in range(q):
   if solve(0,M[j]):
      print "yes"
   else:
      print "no"

Submission status: Runtime Error

Solution code:
n = input()
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1

Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = input()
f = [for i in range(2000)] = [1]
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1
 
Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = input()
f = [for i in range(n)]
f = 0
f[1] = 1
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1
 
Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = input()
f = [for i in range(2000)]
f = []
f[1] = 1
for i in range(n):
  A = map(int, raw_input().split())
  j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1
 
Q = input()
for i in range(Q)
  m = map(int, raw_input().split())
  if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, raw_input().split())
Q = input()
f = [for i in range(2000)]
f = []
f[1] = 1
m = map(int, raw_input().split())

for i in range(n):
    j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1

for i in range(Q)
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n = input()
A = map(int, raw_input().split())
Q = input()
f = {0}
f[1] = 1
m = map(int, raw_input().split())

for i in range(n):
    j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j + 1] == 1):
      f[j + A + 1] == 1
    j- = 1

for i in range(Q)
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

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

Q = input()
m = map(int, raw_input().split())

f = []

for i in range(n):
    j = 2000
  while 0 < j:  
    if(j + A < 2000 && f[j] == 1):
      f[j + A] == 1
    j- = 1

for i in range(Q)
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

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

Q = input()
m = map(int, raw_input().split())

f = []

for i in range(n):
    j = 2000
  for j in range(2000):
    if(j + A < 2000 && f[j] == 1):
      f[j + A] == 1
    
for i in range(Q):
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

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

Q = input()
m = map(int, raw_input().split())

f = []
f[0] = 1

for i in range(n):
    j = 2000
  for j in range(2000):
    if(j + A < 2000 && f[j] == 1):
      f[j + A] == 1
    
for i in range(Q):
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

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

Q = input()
m = map(int, raw_input().split())

f = []
f[0] = 1

for i in range(n):
  for j in range(2000):
    if(j + A < 2000 && f[j] == 1):
      f[j + A] == 1
    
for i in range(Q):
    if(f[m] == 1):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

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

Q = input()
m = map(int, raw_input().split())

f = []
f[1] = 1

for i in range(n):
  for j in range(2000):
    if(j + A < 2000 && f[j] == 1):
      f[j + A] == 1
    
for i in range(Q):
    if(f[m - 1] == 1):
      print "yes"
    else:
      print "no"

Submission status: Runtime Error

Solution code:
n=raw_input()
i=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())
if m == 0
  return true
if i >= n
  return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res

Submission status: Runtime Error

Solution code:
n = input()

f = []
f[1] = 1

for i in range(n):
  A[i] = input()
  for j in range(2000):
    if(j + A[i] < 2000 && f[j] == 1):
      f[j + A[i]] == 1
    
Q = input()
for i in range(Q):
  B[i] = input()
    if(f[B[i] - 1] == 1):
      print "yes"
    else:
      print "no"

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    return yes
  else:
    return no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n or sum(A)<m:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n or sum(A)<m:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m)
  if m == 0:
    return true
  if c >= n or sum(A)<m:
    return false
  res = solve(c + 1, m) || solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m)
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) || solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) || solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print yes
  else:
    print no

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print 'yes'
  else:
    print 'no'

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int,raw_input().split())
q=raw_input()
m=map(int,raw_input().split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"

Submission status: Runtime Error

Solution code:
n=raw_input()
A=map(int, raw_input().split())
q=raw_input()
m=map(int, raw_input().split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"