TnT/CodeNet4Repair huggingface dataset:
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):

abcd = input()
num = [int(i) for i in abcd]
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))


Fixed, accepted submission:

abcd = input()
num = [int(i) for i in abcd]
anslist = []
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans+'=7'
            
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
l=[int(input()) for _ in range(3)]
print((l[0]+l[1])//2 * l[2])
                             

Fixed, accepted submission:
l=[int(input()) for _ in range(3)]
print(int((l[0]+l[1])/2*l[2]))
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(20001):
    ans = min(ans, i*c + (x - i//2)*a + (y - i//2)*b)
print(ans)

Fixed, accepted submission:
a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(500000):
    ans = min(ans, i*c + max(0,x - i//2)*a + max(0,y - i//2)*b)
print(ans)
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
X=int(input())
ans=0

for i in range(100):
  for j in range(20):
    if i**j<=X:
      ans=max(ans,i**j)
      
print(ans)

Fixed, accepted submission:
X=int(input())
ans=0

for i in range(1,100):
  for j in range(2,20):
    if i**j<=X:
      ans=max(ans,i**j)
      
print(ans)
Problem:
We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
#A.sort(reverse = True)
Al=list(set(A))
Al.sort(reverse = True)
HW = []
for i in Al:
  n = A.count(i)
  for j in range(min(n//2,2)):
    HW.append(i)
  if len(HW)>=2:
    break
  HW = HW + [0,0]
print(HW[0]*HW[1])

Fixed, accepted submission:
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
  if A[i]==A[i-1]:
    n = A.count(A[i])
    HW += [A[i]]*(min(n//2,2))
    i = i + n -1
  else:
    i = i + 1
  if len(HW)>=2:
    break
if len(HW)<2:
  print(0)
else:
  print(HW[0]*HW[1])
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
input()
num = [int(i) for i in input().split()]
print (min(num),max(num),min(num))

Fixed, accepted submission:
input()
num = [int(i) for i in input().split()]
print (min(num),max(num),sum(num))
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
n=input()

for i in ["a","i","u","e","o"]:
  if i in n:
    print("vowel")
  else:
    print("consonant")

Fixed, accepted submission:
n=input()

if n in ["a","i","u","e","o"]:
  print("vowel")
else:
  print("consonant")
Problem:
We have a grid with H rows and W columns. At first, all cells were painted white.  Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.  Compute the following:    * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?

Incorrect submission (verdict: Wrong Answer):
ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))

h,w,n = ai()
bl = [ai_() for _ in range(n)]
from collections import defaultdict
d = defaultdict(int)

from itertools import product

for a,b in bl:
    for da,db in product((-1,0,1), repeat=2):
        print(a+da,b+db)
        if 0 < a+da < h-1 and 0 < b+db < w-1:
            d[(a+da, b+db)] += 1

print((h-2)*(w-2) - len(d))
l = list(d.values())
for i in range(1, 10):
    print(l.count(i))

Fixed, accepted submission:
ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))

h,w,n = ai()
bl = [ai_() for _ in range(n)]
from collections import defaultdict
d = defaultdict(int)

from itertools import product
l = list(product((-1,0,1), repeat=2))

for a,b in bl:
    for da,db in l:
        if 0 < a+da < h-1 and 0 < b+db < w-1:
            d[(a+da, b+db)] += 1

print((h-2)*(w-2) - len(d))
ll = list(d.values())
for i in range(1, 10):
    print(ll.count(i))
Problem:
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.     

Incorrect submission (verdict: Wrong Answer):
w,h,x,y,r=map(int, input().split())

x_max=int(x+r)
x_min=int(x-r)
y_max=int(y+r)
y_min=int(y-r)

print(x_max,x_min,y_max,y_min)


if y_max >= w:
    print("No")
else:
    if y_min <= 0:
        print("No")
    else:
        if x_max >= h:
            print("No")
        else:
            if x_min <= 0:
                print("No")
            else:
                print("Yes")

Fixed, accepted submission:
w,h,x,y,r=map(int, input().split())

x_max=int(x+r)
x_min=int(x-r)
y_max=int(y+r)
y_min=int(y-r)

#print(x_max,x_min,y_max,y_min)


if y_max > h:
    print("No")
else:
    if y_min < 0:
        print("No")
    else:
        if x_max > w:
            print("No")
        else:
            if x_min < 0:
                print("No")
            else:
                print("Yes")
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
S = input()
S = S[::-1]

divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
    divide[i] = divide[i][::-1]

length1 = 0
length2 = 0
can = 0
flag = True

while flag:
    length1 = length2
    for i in range(4):
        if S[length1:length1+len(divide[i])] == divide[i]:
            length2 = length1 + len(divide[i])
    if length1 == length2:
        flag = False

if len(S) == length2:
    print("YES")
else:
    print("NO")

print(length2)

Fixed, accepted submission:
S = input()
S = S[::-1]

divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
    divide[i] = divide[i][::-1]

length1 = 0
length2 = 0
can = 0
flag = True

while flag:
    length1 = length2
    for i in range(4):
        if S[length1:length1+len(divide[i])] == divide[i]:
            length2 = length1 + len(divide[i])
    if length1 == length2:
        flag = False

if len(S) == length2:
    print("YES")
else:
    print("NO")
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
a = [i for i in input().split()]
b = []

for i in range(len(a)):
   b = a.pop(a.index(min(a)))

print(" ".join(b))

Fixed, accepted submission:
a = [i for i in input().split()]
b = []

for i in range(len(a)):
    b.append(a.pop(a.index(min(a))))

print(" ".join([str(i) for i in b]))
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
num = int(input())
print((1+num)*num/2)

Fixed, accepted submission:
num = int(input())
print((1+num)*num//2)
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
X = input()
X.count('1')

Fixed, accepted submission:
X = input()
print(X.count('1'))
Problem:
In programming, hexadecimal notation is often used.  In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.  In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`.  When X and Y are seen as hexadecimal numbers, which is larger?

Incorrect submission (verdict: Wrong Answer):
print(max(input().split()))


Fixed, accepted submission:
X,Y = map(str,input().split())
if(X > Y):print(">")
if(X is Y):print("=")
if(X < Y):print("<")
Problem:
You are given an integer sequence of length N, a_1,a_2,...,a_N.  For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.  After these operations, you select an integer X and count the number of i such that a_i=X.  Maximize this count by making optimal choices.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
num = list(map(int,input().split()))
lis = [0]*(max(num)+2)
for i in num:
    lis[i-1] +=1
    lis[i] +=1
    lis[i+1] +=1
print(lis)
print(max(lis))


Fixed, accepted submission:
n = int(input())
num = list(map(int,input().split()))
lis = [0]*(max(num)+4)
for i in num:
    if i == 0:
        lis[i] +=1
        lis[i+1] +=1
    else:
        lis[i-1] +=1
        lis[i] +=1
        lis[i+1] +=1
    
print(max(lis))
Problem:
N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int, input().split()))
ans=0
for i in range(1, n):
    s=a[i] - a[i-1]
    if s<0:
        ans-=s
        a[i]-=s

Fixed, accepted submission:
n=int(input())
a=list(map(int, input().split()))
ans=0
for i in range(1, n):
    s=a[i] - a[i-1]
    if s<0:
        ans-=s
        a[i]-=s
print(ans)
Problem:
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.  They start simultaneously at the same point and moves as follows **towards the east** :    * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.   * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.  How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.

Incorrect submission (verdict: Wrong Answer):
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
  print('infinity')
else:
  if A[0]*T[0]+A[1]*T[1] < B[0]*T[0]+B[1]*T[1]:
    C = A
    A = B
    B = C
  if A[0] > B[0]:
    print('0')
  else:
    bcover = (B[0]-A[0])*T[0]
    tcover = A[0]*T[0]+A[1]*T[1] - B[0]*T[0]-B[1]*T[1]
    print(A,B,bcover,tcover, bcover/tcover)
    if bcover%tcover == 0:
      print(int(bcover/tcover)*2)
    else:
      print(int(bcover/tcover)*2+1)

Fixed, accepted submission:
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
  print('infinity')
else:
  if A[0]*T[0]+A[1]*T[1] < B[0]*T[0]+B[1]*T[1]:
    C = A
    A = B
    B = C
  if A[0] > B[0]:
    print('0')
  else:
    bcover = (B[0]-A[0])*T[0]
    tcover = A[0]*T[0]+A[1]*T[1] - B[0]*T[0]-B[1]*T[1]
    if bcover%tcover == 0:
      print(int(bcover/tcover)*2)
    else:
      print(int(bcover/tcover)*2+1)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
print(n%1000)

Fixed, accepted submission:
n=int(input())
ans=1000-n%1000
if ans==1000:
    print(0)
else:
    print(ans)
Problem:
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.  Write a program which computes the amount of the debt in n weeks.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main(): 
	week = int(input())
	base = 100000
	x = 1
	for i in range(week):
		x = round(x * 1.05 + 0.004 ,2)
	print(x)
if __name__ == '__main__':
  main()

Fixed, accepted submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main(): 
	week = int(input())
	base = 100000
	x = base
	for i in range(week):
		x = round(x * 1.05)
		if x % 1000 > 0:
			x = (x // 1000) *1000 +1000
	print(x)
if __name__ == '__main__':
  main()
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
n,l=map(int,input().split())
s=list(map(str,input().split()))
s=sorted(s)
print(s[0])

Fixed, accepted submission:
n,l=map(int,input().split())
s=[]
ss=''
for i in range(n):
	s.append(input())
s=sorted(s)
for i in range(n):
	ss+=s[i]
print(ss)
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
from sys import stdin

num_blue = stdin.readline().rstrip()
word_blue = []

for i in range(int(num_blue)) :
    word_blue.append(stdin.readline().rstrip())
    print(word_blue)

num_red = stdin.readline().rstrip()
word_red = []

for i in range(int(num_red)) :
    word_red.append(stdin.readline().rstrip())
    print(word_red)

counter_max = 0

for i in range(int(num_blue)):
   counter = word_blue.count(word_blue[i]) - word_red.count(word_blue[i])
   if counter > counter_max:
       counter_max = counter

if counter < 0 :
    counter = 0
    
print(counter)
   

Fixed, accepted submission:
from sys import stdin

num_blue = stdin.readline().rstrip()
word_blue = []

for i in range(int(num_blue)) :
    word_blue.append(stdin.readline().rstrip())


num_red = stdin.readline().rstrip()
word_red = []

for i in range(int(num_red)) :
    word_red.append(stdin.readline().rstrip())

counter_max = 0

for i in range(int(num_blue)):
   counter = word_blue.count(word_blue[i]) - word_red.count(word_blue[i])
   if counter > counter_max:
       counter_max = counter
   
print(counter_max)
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x) < min(y):
    print('No war')
else:
    print('War')

Fixed, accepted submission:
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x) < min(y):
    print('No War')
else:
    print('War')
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
if n%1000==0:
  print(n//1000)
else:
  print((n//1000)+1)

Fixed, accepted submission:
n=int(input())
if n%1000==0:
  print(0)
else:
  print(1000*((n//1000)+1)-n)
Problem:
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.  Find the number of chocolate pieces prepared at the beginning of the camp.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
D,X = map(int,input().split())
result = X
for i in range(N):
  A = int(input())
  for j in range(1,D,A):
    result += 1 
print(result)

Fixed, accepted submission:
N = int(input())
D,X = map(int,input().split())
result = X
for i in range(N):
  A = int(input())
  for j in range(1,D+1,A):
    result += 1 
print(result)
Problem:
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:    * Hit his pocket, which magically increases the number of biscuits by one.   * Exchange A biscuits to 1 yen.   * Exchange 1 yen to B biscuits.  Find the maximum possible number of biscuits in Snuke's pocket after K operations.

Incorrect submission (verdict: Wrong Answer):
def input_space():
    return list(map(int,input().split(" ")))

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B/A
    k=c-1
    t=(K-A+1)//2
    mod=(K-A+1)%2

    res=A+t*k*A+mod

print(res)

Fixed, accepted submission:
def input_space():
    return list(map(int,input().split(" ")))

K,A,B=input_space()

if B-A<=2:
    res=K+1
else:
    c=B-A
    k=c-1
    t=max(0,(K-A+1)//2)
    mod=(K-A+1)%2
    res=A+t*c+mod



print(res)
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
N=int(input())
A=int(input())
a=int(N/500)
if N-a*500<=A:
    print("Yes")
else :
    print("No")

Fixed, accepted submission:
X=int(input())
A=int(input())
B=int(input())
a=X-A
b=int(a/B)
print(a-b*B)
Problem:
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 _M i_.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
    A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
    B[i]=int(B[i])
    c=0
    for j in range(n-1):
        for k in range(j+1,n):
            sum=A[j]+A[k]
            if sum==B[i] and c==0:
                c+=1
                C.append("yes")
    if c==0:
        C.append("no")
for i in range(q):
    print(C[i])



Fixed, accepted submission:
import itertools
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
    A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
    B[i]=int(B[i])
l=[0,1]
p=[]
k=0
D=[]
for v in itertools.product(l,repeat=n):
    sum=0
    for i in range(n):
        if v[i]==1:
            sum=sum+A[i]
    D.append(sum)
    k+=1
for i in range(q):
    if B[i] in D:
        C.append("yes")
    else:
        C.append("no")
for i in range(q):
    print(C[i])