TnT/CodeNet4Repair huggingface dataset:
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())
print(((a+b)*h)/2)

Fixed, accepted submission:
a=int(input())
b=int(input())
h=int(input())
print(int(((a+b)*h)/2))
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
a, b,c = map(int, input().split())
if [5,5,7] == [a,b,c].sort() :
    print("YES")
else :
    print("NO")

Fixed, accepted submission:
a, b,c = map(int, input().split())
list = sorted([a,b,c])
if [5,5,7] == list :
  print("YES")
else :
  print("NO")
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
x=int(input())
year=0
for i in range(0,x+1):
  year+=(x*1/100)
print(year)

Fixed, accepted submission:
x=int(input())
c=100
year=0
while (c<=x):
  if(c==x):
    break
  year+=1
  c+=(c*1//100)
print(year)
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a,b,c = input().split();print("YNeos"[a[-1]!=b[0] or b[-1]!=c[0]::2])

Fixed, accepted submission:
a,b,c = input().split();print("YNEOS"[a[-1]!=b[0] or b[-1]!=c[0]::2])
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().split())
l = [a,b,c]
if (min(l)==c)|(max(l)==c):
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
a,b,c = map(int, input().split())
l = [a,b,c]
if (min(l)==c)|(max(l)==c):
    print('No')
else:
    print('Yes')
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):
s = str(input())
if s[0]=='9' or s[1]=='9':
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
s = str(input())
if s[0]=='9' or s[1]=='9':
  print('Yes')
else:
  print('No')
Problem:
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.  The i-th operation is as follows:    1. Append a_i to the end of b.   2. Reverse the order of the elements in b.  Find the sequence b obtained after these n operations.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(n):
  if i%2 == 0:
    ans.append(a[i])
  else:
    ans.insert(0,a[i])
for an in ans:
  print(an,end=' ')

Fixed, accepted submission:
n = int(input())
a = list(map(int,input().split()))
odd = []
even = []
o = 0
e = 1
while o < n:
  odd.append(str(a[o]))
  o += 2
while e < n:
  even.append(str(a[e]))
  e += 2
if n%2 == 0:
  ans = even[::-1]+odd
else:
  ans = odd[::-1]+even
print(' '.join(ans))
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-n//1000*1000)

Fixed, accepted submission:
n = int(input())
print(1000-(n-n//1000*1000) if n%1000 != 0 else 0)
Problem:
Write a program which solve a simultaneous equation:      ax + by = c   dx + ey = f      The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.

Incorrect submission (verdict: Wrong Answer):
while True:
	try:
		a,b,c,d,e,f = map(int, input().split())
		x = (c*d-a*f)/(b*d-a*e)
		print("{:.3f} {:.3f}".format(x,c-b*x/a))
	except:
		break


Fixed, accepted submission:
while True:
	try:
		a,b,c,d,e,f = map(int, input().split())
		x = (c*d-a*f)/(b*d-a*e)
		print("{:.3f} {:.3f}".format((c-b*x)/a, x))
	except:
		break
Problem:
We have a grid with N rows and M columns of squares. Initially, all the squares are white.  There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted.  Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.

Incorrect submission (verdict: Wrong Answer):
N, M, K = map(int, input().split())
cnt = 1

for i in range(100000):
    cnt *= 2
    if cnt == K:
        print("Yes")
else:
    print("No")
    

Fixed, accepted submission:
N, M, K = map(int, input().split())

for i in range(N+1):
    for j in range(M+1):
        if K == (N-i)*j + (M-j)*i:
            print("Yes")
            exit()

print("No")
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

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

for i in range(len(n)):
    if n[i] == " ":
        if ans:
            ans = ans[:-1]
    else:
        ans +=n[i]

print(ans)


Fixed, accepted submission:
n =input()
ans=""

for i in range(len(n)):
    if n[i] == "B":
        if ans:
            ans = ans[:-1]
    else:
        ans +=n[i]

print(ans)
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):
s1, s2, s3 = input().capitalize().split()
print(s1[0]+s2[0]+s3[0])

Fixed, accepted submission:
s1, s2, s3 = input().upper().split()
print(s1[0]+s2[0]+s3[0])
Problem:
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.

Incorrect submission (verdict: Wrong Answer):
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    ac = collections.Counter(A)
    bc = collections.Counter(B)

    for k in ac.keys():
        if N - bc[k] < ac[k]:
            print("No")
            return


    ans = []
    q = collections.deque()

    print("Yes")
    for i in range(N):
        b = B.pop()
        if A[i] != b:
            ans.append(b)
        else:
            c = B.pop()
            ans.append(c)
            B.append(b)
    print(*ans)




if __name__ == '__main__':
    main()


Fixed, accepted submission:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    ac = collections.Counter(A)
    bc = collections.Counter(B)

    for i in range(1, N + 1):
        if ac[i] + bc[i] > N:
            print("No")
            return

    ma = 0
    cnta = 0
    cntb = 0
    for i in range(1, N + 1):
        cnta += ac[i]
        cntb += bc[i - 1]
        ma = max(ma, cnta - cntb)

    print("Yes")

    ans = B[N - ma:] + B[:N - ma]
    print(*ans)


if __name__ == '__main__':
    main()
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):

while True:
    t = input()
    if t.find("?") > 0:
        break
    print(eval(t))

Fixed, accepted submission:
while True:
    t = input()
    if t.find("?") > 0:
        break
    print(int(eval(t)))
Problem:
スピードスケートバッジテストでは、2 種類の距離で規定されたタイムを上回った場合に級が認定されます。例えば A 級になるには 500 M で 40.0 秒未満、かつ 1000 M で 1 分 23 秒未満であることが求められます。  スピードスケート大会 (500 M と 1000 M) で記録したタイムを入力とし、スピードスケートバッジテストで何級に相当するかを出力するプログラムを作成して下さい。500 M と1000 M のバッジテスト規定タイムは下表のとおりです。 E 級に満たなかった場合には、NA と出力してください。  |  500 M| 1000 M   ---|---|---   AAA 級|  35 秒 50|  1 分 11 秒 00   AA 級 |  37 秒 50|  1 分 17 秒 00   A 級 |  40 秒 00|  1 分 23 秒 00   B 級 |  43 秒 00|  1 分 29 秒 00   C 級 |  50 秒 00|  1 分 45 秒 00   D 級 |  55 秒 00|  1 分 56 秒 00   E 級 | 1分10 秒 00 | 2 分 28 秒 00

Incorrect submission (verdict: Wrong Answer):
[a, b] = [float(num) for num in input().split()];

if (a < 35.5) & (b < 71.0):
	print('AAA');
elif (a < 37.5) & (b < 77.0):
	print('AA');
elif (a < 40.0) & (b < 83.0):
	print('A');
elif (a < 43.0) & (b < 89.0):
	print('B');
elif (a < 50.0) & (b < 105.0):
	print('C');
elif (a < 55.0) & (b < 116.0):
	print('D');
elif (a < 70.0) & (b < 148.0):
	print('E');
else:
	print('NA');

Fixed, accepted submission:
import sys

for line in sys.stdin:
	[p, q] = line.split();
	a = float(p);
	b = float(q);
	
	if (a < 35.5) & (b < 71.0):
		print('AAA');
	elif (a < 37.5) & (b < 77.0):
		print('AA');
	elif (a < 40.0) & (b < 83.0):
		print('A');
	elif (a < 43.0) & (b < 89.0):
		print('B');
	elif (a < 50.0) & (b < 105.0):
		print('C');
	elif (a < 55.0) & (b < 116.0):
		print('D');
	elif (a < 70.0) & (b < 148.0):
		print('E');
	else:
		print('NA');
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
def insertion_sort(target_list):
    '????????????????????????????????\???????????§??????????????????????????¨?????????'
    sorted_list = list()
    for target in target_list[:]:
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
        print(sorted_list + target_list)

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A)

Fixed, accepted submission:
def insertion_sort(target_list):
    sorted_list = list()
    for target in target_list[:]:
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
        print(' '.join(str(s) for s in sorted_list + target_list))

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A)
Problem:
You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number of times.  Write a program which reports the minimal total cost to sort the given integers.

Incorrect submission (verdict: Wrong Answer):
import copy
n = int(input())
a = list(map(int, input().split()))
b = copy.deepcopy(a)
b.sort()
loop = []
minp = min(a)
t = [0 for i in range(n)]
while True:
    i = t.index(0)
    j = len(loop)
    loop.append([a[i]])
    t[i] = 1
    while True:
        i = b.index(a[i])
        if t[i] == 1:
            break
        t[i] = 1
        loop[j].append(a[i])
    if sum(t) == n:
        break
    j += 1
print(loop)
cost = 0
for i in loop:
    if len(i) == 1:
        continue
    ps = sum(i)
    pl = len(i)
    pm = min(i)
    p1 = ps + (pl - 2) * pm
    p2 = ps + pm + (pl + 1) * minp
    cost += min(p1, p2)
print(cost)


Fixed, accepted submission:
import copy
n = int(input())
a = list(map(int, input().split()))
b = copy.deepcopy(a)
b.sort()
loop = []
minp = min(a)
t = [0 for i in range(n)]
while True:
    i = t.index(0)
    j = len(loop)
    loop.append([a[i]])
    t[i] = 1
    while True:
        i = b.index(a[i])
        if t[i] == 1:
            break
        t[i] = 1
        loop[j].append(a[i])
    if sum(t) == n:
        break
    j += 1
cost = 0
for i in loop:
    if len(i) == 1:
        continue
    ps = sum(i)
    pl = len(i)
    pm = min(i)
    p1 = ps + (pl - 2) * pm
    p2 = ps + pm + (pl + 1) * minp
    cost += min(p1, p2)
print(cost)
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
if n // 1.08 == int((n // 1.08) * 1.08):
    print(n//1.08)
else:
    print(":(")

Fixed, accepted submission:
import sys
import math
n = int(input())
for i in range(n+1):
    if math.floor(i * 1.08) == n:
        print(i)
        sys.exit()
print(":(")
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
h,w = [int(i) for i in input().split()]

print('#' * (w + 2))

for i in range(h):
  str = input()
  str = '*' + str + '*'
  print(str)

print('#' * (w + 2))

Fixed, accepted submission:
h,w = [int(i) for i in input().split()]

print('#' * (w + 2))

for i in range(h):
  str = input()
  str = '#' + str + '#'
  print(str)

print('#' * (w + 2))
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):
lis = list(map(int,input().split()))

def counter(x):
  count = 0 
  while x%2 ==0:
    x = x/2
    count += 1
  return count

ans = 0
for i in lis:
  if counter(i) > ans:
    ans = counter(i)
print(counter(i))
    

Fixed, accepted submission:
def counter(a):
  count = 0 
  while a%2 ==0:
    a /= 2
    count += 1
  return count
N = int(input())
s = [int(n) for n in input().split()]
print(min([counter(a) for a in s]))
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):
n,a,b = list(map(int,input().split()))

s = input()

for i in s:
    if i == 'c':
        print('no')
    elif i == 'a' and (a+b>=1):
        if a>0:
            a -= 1
        else:
            b -= 1
        print('yes')
    elif i =='b' and b > 0:
        b -= 1
        print('yes')
    else:
        print('no')

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

s = input()

for i in s:
    if i == 'c':
        print('No')
    elif i == 'a' and (a+b>=1):
        if a>0:
            a -= 1
        else:
            b -= 1
        print('Yes')
    elif i =='b' and b > 0:
        b -= 1
        print('Yes')
    else:
        print('No')
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 b_shift_only(N, A):
    
    
    a_min = float('inf')
    for a in A:
        if a % 2 == 1:
            return 0
        a_min = min(a_min, a)
    
    ans = 0
    while a_min % 2 == 0:
        a_min //= 2
        ans += 1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(b_shift_only(N, A))

Fixed, accepted submission:
def b_shift_only(N, A):
    
    
    bitwise_or = 0
    for a in A:
        bitwise_or |= a
    
    ans = 0
    while bitwise_or % 2 == 0:
        bitwise_or //= 2
        ans += 1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(b_shift_only(N, A))
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):
g1=[1,3,5,7,8,10,12]
g2=[4,6,9,11]
g3=[2]
a,b=map(int,input().split())
for i in g1:
  if a==i:
    n1=1
  if b==i:
    n2=2
for i in g2:
  if a==i:
    n1=2
  if b==i:
    n2=2
for i in g3:
  if a==i:
    n1=3
  if b==i:
    n2=3
    
if n1==n2:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
m=[1,3,1,2,1,2,1,1,2,1,2,1]
a,b=map(int,input().split())    
if m[a-1]==m[b-1]:
  print("Yes")
else:
  print("No")
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

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

kinds = set(colors)
print(kinds)

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

kinds = len(set(colors))
print(kinds)
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):


N=int(input())

print((N+1)*N/2)

Fixed, accepted submission:


N=int(input())

print(int((N+1)*N/2))
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while True:
    a,op,b = input().split()
    A = int(a)
    B = int(b)

    if op == '?': break
    elif op == '+':
        print(A+B)
    elif op == '-':
        print(A-B)
    elif op == '*':
        print(A*B)
    elif op == '/':
        print(A/B)
        


Fixed, accepted submission:
while True:
    a,op,b = input().split()

    A = int(a)
    B = int(b)

    if op == '?': break
    elif op == '+':
        print(A+B)
    elif op == '-':
        print(A-B)
    elif op == '*':
        print(A*B)
    elif op == '/':
        print(A//B)
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
data = {'AC':0,'WA':0,'TLE':0,'RE':0}
N = int(input())
for i in range(N):
  inputSTR = input()
  data[inputSTR] = data[inputSTR] + 1
  
for key,value in data.items():
  print(key + ' × ' + str(value))


Fixed, accepted submission:
data = {'AC':0,'WA':0,'TLE':0,'RE':0}
N = int(input())
for i in range(N):
  inputSTR = input()
  data[inputSTR] = data[inputSTR] + 1
  
for key,value in data.items():
  print(key + ' x ' + str(value))
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):
str=list(input())
print(str)
s1=int(str[0])
s2=int(str[1])
s3=int(str[2])
print(s1+s2+s3)


Fixed, accepted submission:
str=list(input())
s1=int(str[0])
s2=int(str[1])
s3=int(str[2])
print(s1+s2+s3)