TnT/CodeNet4Repair huggingface dataset:
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):
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr

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

for i in m:
    yesorno = False
    b = []
    for j in a:
        if j < i:
            b.append(j)
    #print(b)
    if len(b)>2:
        for r in range(2, len(b)+1):
            for comb in itr.combinations(b,r):
                #print(i,comb)
                if sum(comb) == i:
                    yesorno = True
                    break
            if yesorno:
                break
    if yesorno:
        print('yes')
    else:
        print('no')


Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a_r1  
@author: maezawa
"""
import itertools as itr

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

sum_array = []
for r in range(1,n+1):
    for comb in itr.combinations(a, r):
        sum_array.append(sum(comb))
sum_array.sort()

for i in m:
    left = 0
    right = len(sum_array)
    yesorno = 'no'
    while(left < right):
        #print(left, right)
        mid = (left+right)//2
        if sum_array[mid] == i:
            yesorno = 'yes'
            break
        elif sum_array[mid] > i:
            right = mid
        else:
            left = mid+1
            
    print(yesorno)
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a, v = input().split(' ')
a = int(a)
v = int(v)
b, u = input().split(' ')
b = int(b)
u = int(u)
t = int(input())


if v < u:
  print('No')
elif a + v * t >= b + u * t :
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a, v = input().split(' ')
a = int(a)
v = int(v)
b, u = input().split(' ')
b = int(b)
u = int(u)
t = int(input())


if a <= b and a + v * t >= b + u * t :
  print('YES')
elif a > b and a - v * t <= b - u * t :
  print('YES')
else:
  print('NO')
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().split())
if b - a == c - b:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
a,b,c = map(int, input().split())
if b - a == c - b:
    print("YES")
else:
    print("NO")
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print(N%24 + 24)

Fixed, accepted submission:
N = int(input())
print(24-N+24)
Problem:
M-kun is a student in Aoki High School, where a year is divided into N terms.   There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:    * For the first through (K-1)-th terms: not given.   * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term.  M-kun scored A_i in the exam at the end of the i-th term.   For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.

Incorrect submission (verdict: Wrong Answer):
n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

for i in range(k, n):
    if a[i]>a[i-k]:
        print('Yes')
    else:
        print("N0")

Fixed, accepted submission:
n,k = list(map(int,input().split()))

a = list(map(int,input().split()))

for i in range(k, n):
    if a[i]>a[i-k]:
        print('Yes')
    else:
        print("No")
Problem:
Write a program which performs a sequence of commands to a given string $str$. The command is one of:    * print a b: print from the a-th character to the b-th character of $str$   * reverse a b: reverse from the a-th character to the b-th character of $str$   * replace a b p: replace from the a-th character to the b-th character of $str$ with p  Note that the indices of $str$ start with 0.

Incorrect submission (verdict: Wrong Answer):
def main():

    strTxt = input()
    n = int(input())
    for _ in range(n):
        strCmd = input().split()
        
        if strCmd[0] == 'print':
            funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
        elif strCmd[0] == 'reverse':
            strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))
            print(strTxt)
        elif strCmd[0] == 'replace':
            strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])
            print(strTxt)


def funcPrint(strInput: str,a: int,b: int):
    print(strInput[a:b+1])

def funcReverse(strInput: str,a: int,b: int):
#    print(strInput[:a]+strInput[b:a:-1]+strInput[b:])
    if a == 0:
        return strInput[b::-1]+strInput[b+1:]
    else:
        return strInput[:a]+strInput[b:a-1:-1]+strInput[b+1:]

def funcReplace(strInput: str,a: int,b: int, strAfter: str):
    return strInput[:a]+strAfter+strInput[b+1:]


if __name__ == '__main__':
    main()



Fixed, accepted submission:
str = input()
n = int(input())

for _ in range(n):
    cmd = list(input().split())
    command, a, b = cmd[0], int(cmd[1]), int(cmd[2])
    if command == 'replace':
        str = str[:a] + cmd[3] + str[b+1:]
    elif command == 'reverse':
        str = str[:a] + str[a:b+1][::-1] + str[b+1:]
    elif command == 'print':
        print(str[a:b+1])
    else:
        pass
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
x, a, b = map(int, input().split())

if a-b > 0:
    print("delicious")

elif b > x+a:
    print("dangerous")

elif b <= x:
    print("safe")


Fixed, accepted submission:
x, a, b = map(int, input().split())

if a-b >= 0:
    print("delicious")

if a-b < 0:
    if b-a <= x:
        print('safe')
if b > x+a:
    print("dangerous")
Problem:
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.  Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).  Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:    * If a_i = 1, he painted the region satisfying x < x_i within the rectangle.   * If a_i = 2, he painted the region satisfying x > x_i within the rectangle.   * If a_i = 3, he painted the region satisfying y < y_i within the rectangle.   * If a_i = 4, he painted the region satisfying y > y_i within the rectangle.  Find the area of the white region within the rectangle after he finished painting.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
W, H, N = map(int, input().split())

g = np.array([[1] * W for _ in range(H)])

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        g[:,:x] = 0
    elif a == 2:
        g[:,x:] = 0
    elif a == 3:
        g[H - y - 1:,:] = 0
    elif a == 4:
        g[:H - y - 1,:] = 0

print (g.sum())


Fixed, accepted submission:
W, H, N = map(int, input().split())

G = [[1] * H for _ in range(W)]

for _ in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        for x_ in range(x):
            for y_ in range(H):
                G[x_][y_] = 0

    if a == 2:
        for x_ in range(x, W):
            for y_ in range(H):
                G[x_][y_] = 0
    
    if a == 3:
        for x_ in range(W):
            for y_ in range(y):
                G[x_][y_] = 0
    
    if a == 4:
        for x_ in range(W):
            for y_ in range(y, H):
                G[x_][y_] = 0

ans = 0
for g in G:
    # print (g)
    ans += sum(g)

print (ans)
Problem:
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.  Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s.  Given the name of the contest, print the abbreviation of the name.

Incorrect submission (verdict: Wrong Answer):
a,b,c = input().split()
print(a[0],b[0],c[0],end ='')

Fixed, accepted submission:
print('A' + input()[8] + 'C')
Problem:
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.  The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.  How many different PIN codes can he set this way?  Both the lucky number and the PIN code may begin with a 0.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
S=input()

ans=0

for i in range(10):
  if str(i) in S:
    a = S.find(str(i))
    for j in range(10):
      if str(j) in S[a+1:]:
      	b = S[a+1:].find(str(j))
      	for k in range(10):
          if str(k) in S[a+b+2:]:
            ans+=1
            print(i,j,k)

print(ans)

Fixed, accepted submission:
N=int(input())
S=input()

ans=0

for i in range(10):
  if str(i) in S:
    a = S.find(str(i))
    for j in range(10):
      if str(j) in S[a+1:]:
      	b = S[a+1:].find(str(j))
      	for k in range(10):
          if str(k) in S[a+b+2:]:
            ans+=1

print(ans)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
def resolve():
    n = int(input())
    arr = (int(x) for x in input().split())

    res = 0
    while True:
        even = list(filter(lambda x: x%2 == 0, arr))
        if len(even) > 0:
            res += 1
        else:
            print(res)
            return

resolve()

Fixed, accepted submission:
def resolve():
    n = int(input())
    arr = list(map(int, input().split()))

    res = 0
    while True:
        exist_odd = False
        for num in arr:
            if num % 2 != 0:
                exist_odd = True

        if exist_odd:
            break

        arr = list(map(lambda x: int(x/2), arr))
        res += 1

    print(res)

resolve()
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
print(int(input())*(2440//3))

Fixed, accepted submission:
a=int(input())
print(800*a-200*(a//15))
Problem:
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors.  Find the number of the possible ways to paint the balls.

Incorrect submission (verdict: Wrong Answer):
N,K = map(int,input().split())
print(K*(K-1)**N-1)

Fixed, accepted submission:
N,K = map(int,input().split())
print(K*(K-1)**(N-1))
Problem:
Snuke, who loves animals, built a zoo.  There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.  There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.  Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species.  More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise.  Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.

Incorrect submission (verdict: Wrong Answer):
def main():
    N = int(input())
    S = input()
    M = [{'o': 0, 'x': 1}, {'o': 1, 'x': 0}]
    for s1, sn in [(0, 0), (0, 1), (1, 0), (1, 1)]:
        T = [s1]
        p, pp = s1, sn
        for s in S:
            pp, p = p, M[p ^ pp][s]
            T.append(p)
        if (s1, sn) == (p, pp):
            return T
    return None

T = main()
if not T:
    print(-1)
else:
    print(''.join('S' if s == 0 else 'W' for s in T))


Fixed, accepted submission:
def main():
    N = int(input())
    S = input()
    M = [{'o': 0, 'x': 1}, {'o': 1, 'x': 0}]
    for s1, sn in [(0, 0), (0, 1), (1, 0), (1, 1)]:
        T = [s1]
        p, pp = s1, sn
        for s in S:
            pp, p = p, M[p ^ pp][s]
            T.append(p)
        if (s1, sn) == (p, pp):
            return T[:-1]
    return None

T = main()
if not T:
    print(-1)
else:
    print(''.join('S' if s == 0 else 'W' for s in T))
Problem:
Write a program which reads a sequence and prints it in the reverse order.

Incorrect submission (verdict: Wrong Answer):
a=list(map(int, input().split()))
a.reverse()
print(*a)


Fixed, accepted submission:
input()
a=list(map(int, input().split()))
a.reverse()
print(*a)
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):
a = int(input())
b = int(input())
h = int(input())

ans = (a+b)*h / 2

print(ans)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())

ans = (a+b)*h / 2

print(int(ans))
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
import math

a=input()
a=sorted(a)
print("Yes" if a=="abs" else "No")


Fixed, accepted submission:
import math

a=input()
a=sorted(a)
print("Yes" if a==["a","b","c"] else "No")
Problem:
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(str,input().split())
print(a[0],b[0],c[0],sep='')


Fixed, accepted submission:
a,b,c=map(str,input().split())
d=str(a[0]+b[0]+c[0])
print(d.upper())
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Time Limit Exceeded):
N = int(input())

for x in range(1,N+1):
  cnt = 0
  for i in range(1,100):
    for j in range(1,100):
      for k in range(1,100):
        if (i+j+k)**2-(i*j+i*k+j*k) == x:
          cnt += 1
  
  print(cnt)

Fixed, accepted submission:
N = int(input())

ans = [0]*10050

for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = (i+j+k)**2-(i*j+i*k+j*k)
      if v < len(ans):
        ans[v] += 1
  
for x in range(1,N+1):
  print(ans[x])
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):

H,W=[int(x) for x in input().split()]
if(H%3==0 or W%3==0):
    print(0)
if(H>W):
    min_dif=W
else:
    min_dif=H
    
if(H%2!=0):
    for i in range(W-1):
        A=(i+1)*H
        B=(W-(i+1))*int(H/2)
        C=H*W-A-B
        D=[A,B,C]
        D.sort()
        if(min_dif>abs(D[0]-D[2])):
            min_dif=abs(D[0]-D[2])
            
if(H%2==0):
    for i in range(W-1):
        A=(i+1)*H
        B=(W-(i+1))*int(H/2)
        if(min_dif>abs(A-B)):
            min_dif=abs(A-B)
            
if(W%2!=0):
    for i in range(H-1):
        A=W*(i+1)
        B=int(W/2)*(H-(i+1))
        C=H*W-A-B
        D=[A,B,C]
        D.sort()
        if(min_dif>abs(D[0]-D[2])):
            min_dif=abs(D[0]-D[2])
            
if(W%2==0):
    for i in range(H-1):
        A=W*(i+1) 
        B=int(W/2)*(H-(i+1))
        if(min_dif>abs(A-B)):
            min_dif=abs(A-B)
print(min_dif)

Fixed, accepted submission:
S=[0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
a,b=[int(x) for x in input().split()]
if(S[a-1]==S[b-1]):
    print("Yes")
else:
    print("No")
Problem:
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.  Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:    * Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.  The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.  X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?

Incorrect submission (verdict: Wrong Answer):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
  print(abs(w-a[-1]))
else:
  print(max(w-a[-1], a[-1]-a[-2]))

Fixed, accepted submission:
n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
  print(abs(w-a[-1]))
else:
  print(max(abs(w-a[-1]), abs(a[-1]-a[-2])))
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Incorrect submission (verdict: Wrong Answer):
n = input()
if (n[0]==9) or (n[1]==9):
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
n = input()
if (n[0]=="9") or (n[1]=="9"):
    print("Yes")
else:
    print("No")
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
i = list(map(int,input().split()))
person = i[1] + i[2]
B = i[2]
rank = input()
passp = 0
bp = 0
for i,r in enumerate(rank):
	if r == "a" and passp < person:
		print("Yes")
		passp += 1
	elif r == "b":
		bp += 1
		if passp < person and bp <=B:
			print("Yes")
			passp += 1
	else:
		print("No")

Fixed, accepted submission:
N,A,B = map(int,input().split())
student = input()
passp = 0
passb = 0
ab = (A+B)
for s in student:
	if s == "a":
		if passp < ab:
			passp += 1
			print("Yes")
		else:
			print("No")
	elif s == "b":
		if passp < ab and passb < B:
			passp += 1
			passb += 1
			print("Yes")
		else:
			print("No")
	else:
		print("No")
Problem:
English text is not available in this practice contest.  ある貧乏な国のおてんばで勇敢なお姫様は，ある日部屋の壁を壊してお城を抜け出し，競馬などのギャンブルが行われている賭博場に入っていった．ところが，ギャンブルなどやったことのないお姫様は，非常に負けが込んでしまった．この状況をおもしろくないと思ったお姫様は，一体どのような仕組みでギャンブルが行われているかを調べてみた．すると，このようなギャンブルではパリミュチュエル方式と呼ばれる方式で配当が決定されていることを突き止めた．  パリミュチュエル方式とは，競走を対象としたギャンブルにおいて配当を決定するために使用する計算方法である．この方式では，全ての掛け金をプールし，一定の割合を控除した上で，当選者に掛け金に比例した金額を分配する．  現在お姫様が熱中しているギャンブルは，参加者は競技前にどの競技者が優勝するかを予想する 1枚100ゴールドの投票券を購入し，競技の結果が予想と一致すれば当選金を受け取る権利を得るというものである．なお，ゴールドはこの国の通貨単位である．あなたの仕事は入力として与えられる競技の情報をもとに，投票券一枚あたりの配当を計算するプログラムを書くことである．  先述の方法で計算される配当額が整数にならない場合は，切り捨てによって整数にすること．

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/python
# -*- coding: utf-8 -*-
import math

while True:
    amount, number, per = map(int, input().split())
    if amount == 0 and number == 0 and per == 0:
        break

    vote = []
    for i in range(amount):
        vote.append(int(input()))

    if vote[number-1] == 0:
        print("0")
    else:
        print(math.floor((100 * sum(vote) * (per / 100)) / vote[number-1]))

Fixed, accepted submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import math

while True:
    amount, number, per = map(int, input().split())
    if amount == 0 and number == 0 and per == 0:
        break

    vote = [int(input()) for _ in range(amount)]

    if vote[number-1] == 0:
        print("0")
    else:
        print(math.floor(100 * sum(vote) * (100 - per) / 100 / vote[number-1]))