Buggy python submission (verdict: Runtime Error):
n = raw_input()
A = map(int, raw_input().split())
d = {}
 
def solution(i, m, n):
    if m == 0:
        return True
    if i >= n:
        return False
    if d.has_key((i, m)):
        return d[(i, m)]
    res = solution(i + 1, m, n) or solution(i + 1, m - A[i], n)
    d[(i, m)] = res
    return res
 
 
q = raw_input()
M = map(int, raw_input().split())
for m in M:
    if solution(0, m, n):
        print 'yes'
    else:
        print 'no'

Fixed submission:
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Buggy python submission (verdict: Runtime Error):
n = raw_input()
A = map(raw_input().split())
d = {}
 
def solution(i, m, n):
    if m == 0:
        return True
    if i >= n:
        return False
    if d.has_key((i, m)):
        return d[(i, m)]
    res = solution(i + 1, m, n) or solution(i + 1, m - A[i], n)
    d[(i, m)] = res
    return res
 
 
q = raw_input()
M = map(raw_input().split())
for m in M:
    if solution(0, m, n):
        print 'yes'
    else:
        print 'no'

Fixed submission:
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Buggy python submission (verdict: Runtime Error):
n,q = raw_input()
A,m = map(int, raw_input().split())
 
def ans(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:
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Buggy python submission (verdict: Runtime Error):
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        f3(n, AA[1:], x)
        try:
            x[tmp] = 1
            f3(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
f3(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Fixed submission:
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Buggy python submission (verdict: Runtime Error):
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
f3(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'

Fixed submission:
def ans(n, AA, x):
    tmp = n + AA[0]
    if len(AA) == 1:
        try: x[tmp] = 1
        except: pass
    else:
        ans(n, AA[1:], x)
        try:
            x[tmp] = 1
            ans(tmp, AA[1:],x)
        except:
            pass
    return
 
n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
M = map(int, raw_input().split())
 
x = [0 for i in range(max(M)+1)]
ans(0, A, x)
 
for e in M:
    if x[e] == 1:
        print 'yes'
    else:
        print 'no'