Buggy python submission (verdict: Runtime Error):
n = input()

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

q = input()

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

for i in range(q):
  for j in range(n):
    if A[n-j] < m[i]:
      m[i] = m[i] - A[n-j]
    if m[i] <= 0:
      break
  if m[i] == 0:
    print "yes"
  else:
    print "no"

Fixed submission:
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"

Buggy python submission (verdict: Runtime Error):
n = input()

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

for i in m:
  for j in range(n):
    if A[-j] <= i
      i = i - A[-j]
    if i <= 0:
      break
  if i == 0:
    print "yes"
  else:
    print "no"

Fixed submission:
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"

Buggy python submission (verdict: Runtime Error):
n = input()

A = {}
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, m) or solve(i, m - A[i])
  return res


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

Fixed submission:
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"

Buggy python submission (verdict: Runtime Error):
n = input()
 
A = {}
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, m) or solve(i, m - A[i])
  return res
 
 
for m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

Fixed submission:
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"

Buggy python submission (verdict: Time Limit Exceeded):
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 m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

Fixed submission:
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"

Buggy python submission (verdict: Time Limit Exceeded):
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 m in M:
  if solve(0,m):
    print "yes"
  else:
    print "no"

Fixed submission:
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"

Buggy python submission (verdict: Runtime Error):
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"

Fixed submission:
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"