Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m,A):
    global n
    if m == 0 :
        return True
    elif i >= n :
        return False
    else:
        return (solve(i+1,m,A) or solve(i+1,m-A[i],A))

global n
n = int(input())
st = input()
A = list(map(int,st.split()))
# dont use q(num of ans patarn) dumping!
input()
st = input()
ans = list(map(int,st.split()))

for x in ans:
    if(solve(0,x,A) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m,A):
    global n
    if m == 0 :
        return True
    elif i >= n :
        return False
    elif m < 0:
        return False
    else:
        return (solve(i+1,m,A) or solve(i+1,m-A[i],A))

global n
n = int(input())
st = input()
A = list(map(int,st.split()))
# dont use q(num of ans patarn) dumping!
input()
st = input()
ans = list(map(int,st.split()))

for x in ans:
    if(solve(0,x,A) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    global n
    global A
    if m == 0 :
        return True
    elif i >= n :
        return False
    else:
        return (solve(i+1,m) or solve(i+1,m-A[i]))

global n
global A
n = int(input())
st = input()
A = list(map(int,st.split()))
input()     # don't use q(num of ans pattern) dumping!
st = input()
ans = list(map(int,st.split()))

for x in ans:
    if(solve(0,x) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    global n
    global A
    if m == 0 :
        return True
    elif m < 0:
        return False
    elif i >= n :
        return False
    else:
        return (solve(i+1,m) or solve(i+1,m-A[i]))

global n
global A
n = int(input())
st = input()
A = list(map(int,st.split()))
A.sort(reverse = True)
input()     # don't use the num of ans pattern. dumping!
st = input()
ans = list(map(int,st.split()))

for x in ans:
    if(solve(0,x) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    global n
    global A
    if m == 0 :
        return True
 #   elif m < 0:
 #       return False
    elif i >= n :
        return False
    else:
        return (solve(i+1,m) or solve(i+1,m-A[i]))

global n
global A
n = int(input())
st = input()
A = list(map(int,st.split()))
#A.sort(reverse = True)
input()     # don't use the num of ans pattern. dumping!
st = input()
ans = list(map(int,st.split()))

for x in ans:
    if(solve(0,x) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')

Buggy python submission (verdict: Time Limit Exceeded):
def solve(i,m):
    global n
    global A
    if m == 0 :
        return True
 #   elif m < 0:
 #       return False
    elif i >= n :
        return False
    else:
        return (solve(i+1,m) or solve(i+1,m-A[i]))

global n
global A
n = int(input())
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
#A.sort(reverse = True)
input()     # don't use the num of ans pattern. dumping!
ans = [ int( val ) for val in input().rstrip().split( ' ' ) ]
for x in ans:
    if(solve(0,x) == True):
        print('yes')
    else:
        print('no')

Fixed submission:
is_able_make = [False]*2000

input()

A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int(input())
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]

for i in A:
    for j in range(2000-i,0,-1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if(is_able_make[x] == True):
        print('yes')
    else:
        print('no')