TnT/CodeNet4Repair huggingface dataset:
Problem:
Snuke has N sticks. The length of the i-th stick is l_i.  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.

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

li=list(map(int,input().split()))
li.sort(reverse=True)

ans=0

for k in range(K):
  ans=ans+li[k]

  print(ans)


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

li=list(map(int,input().split()))
li.sort(reverse=True)

ans=0

for k in range(K):
  ans=ans+li[k]

print(ans)
Problem:
Rng is preparing a problem set for a qualification round of CODEFESTIVAL.  He has N candidates of problems. The difficulty of the i-th candidate is D_i.  There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.  Determine whether Rng can complete the problem set without creating new candidates of problems.

Incorrect submission (verdict: Wrong Answer):
import collections

def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    Dcounter = collections.Counter(D)
    Tcounter = collections.Counter(T)
    for t in T:
        if Dcounter[t] - Tcounter[t] < 0:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()


Fixed, accepted submission:
import collections

def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    Dcounter = collections.Counter(D)
    Tcounter = collections.Counter(T)
    for t in T:
        if Dcounter[t] - Tcounter[t] < 0:
            print('NO')
            return
    print('YES')

if __name__ == "__main__":
    main()
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())
value = float('inf')
D = max(A,B)
for i in range(D+1):
  valueX = 2*i*C+(X-i)*A+(Y-i)*B
  if valueX < value:
    value  = valueX
print(str(value))

Fixed, accepted submission:
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(X,Y)
for i in range(D+1):
  E = max((X-i)*A, 0)
  F = max((Y-i)*B, 0)
  valueX = 2*i*C+E+F
  if valueX < value:
    value  = valueX
print(str(value))
Problem:
Write a program which reads a sequence and prints it in the reverse order.

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

for i in l[::-1]:
    print(i)


Fixed, accepted submission:
#
# 6a
#

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    print(*a)


if __name__ == '__main__':
    main()
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
S = int(input())
h = 60
m = 60 * 60
s = 3600 * 60
print(h, m, s, sep=':')

Fixed, accepted submission:
S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60 
print(h, m, s, sep=':')
Problem:
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally).  Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate.  Out of the N materials, how many can produce an H \times W plate if properly cut?

Incorrect submission (verdict: Wrong Answer):
N,H,W=map(int,input().split())
ans=0
for _ in range(N):
    A,B=map(int,input().split())
    if A<=H and B<=W:
        ans+=1
print(ans)

Fixed, accepted submission:
N,H,W=map(int,input().split())
ans=0
for _ in range(N):
    A,B=map(int,input().split())
    if A>=H and B>=W:
        ans+=1
print(ans)
Problem:
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**.  Here, an sequence b is a **good sequence** when the following condition holds true:    * For each element x in b, the value x occurs exactly x times in b.  For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.  Find the minimum number of elements that needs to be removed so that a will be a good sequence.

Incorrect submission (verdict: Wrong Answer):
import collections

N = int(input())
A = list(map(int, input().split()))

count = collections.Counter()

for a in A:
    count[a] += 1
    
ans = 0

for num, c in count.items():
    if num < c:
        ans += c - num
    elif num > c:
        ans += c
    else:
        continue

Fixed, accepted submission:
import collections

N = int(input())
A = list(map(int, input().split()))

count = collections.Counter()

for a in A:
    count[a] += 1
    
ans = 0

for num, c in count.items():
    if num < c:
        ans += c - num
    elif num > c:
        ans += c
    else:
        continue
        
print(ans)
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
S = input()
T = input()
len_T = len(T)

lst = []
for x in range(len(S) - len_T + 1):
    flg = True
    s = S[x:len_T+x]    
    for idx in range(len_T):
        if s[idx] != '?' and s[idx] != T[idx]:
            flg = False
            break
    if flg:
        tmp = S[:x] + T + S[x + len_T:]
        print(tmp)
        tmp = tmp.replace('?', 'a')
        lst.append(tmp)


if len(lst) == 0:
    print('UNRESTORABLE')
else:
    print(min(lst))


Fixed, accepted submission:
S = input()
T = input()
len_T = len(T)

lst = []
for x in range(len(S) - len_T + 1):
    flg = True
    s = S[x:len_T+x]    
    for idx in range(len_T):
        if s[idx] != '?' and s[idx] != T[idx]:
            flg = False
            break
    if flg:
        tmp = S[:x] + T + S[x + len_T:]
        tmp = tmp.replace('?', 'a')
        lst.append(tmp)


if len(lst) == 0:
    print('UNRESTORABLE')
else:
    print(min(lst))
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import bisect

n = int(input())
a_list = sorted(list(map(int, input().split())))

a_i = a_list.pop()

half = a_i // 2

if len(a_list) == 1:
  print(*[a_i, a_list[0]])
  exit()

left_index = bisect.bisect_left(a_list, half)

if left_index >= 1:
  if a_list[left_index] - half < half - a_list[left_index-1]:
    print(*[a_i, a_list[left_index]])
  else:
    print(*[a_i, a_list[left_index-1]])
if left_index == 0:
  print(*[a_i, a_list[left_index]])

      

Fixed, accepted submission:
import bisect

n = int(input())
a_list = sorted(list(map(int, input().split())))

a_i = a_list.pop()

half = a_i / 2

if len(a_list) == 1:
  print(*[a_i, a_list[0]])
  exit()
  
left_index = bisect.bisect_left(a_list, half)

if left_index >= 1:
  if a_list[left_index] - half < half - a_list[left_index-1]:
    print(*[a_i, a_list[left_index]])
  else:
    print(*[a_i, a_list[left_index-1]])
if left_index == 0:
  print(*[a_i, a_list[left_index]])
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
A, B = map(int, input().split())
S = input()
if A + B + 1 != len(S) or S[A] != '-':
    print('No')
else:
    if '-' in S[:A] or '-' in S[1+1:]:
        print('No')
    else:
        print('Yes')


Fixed, accepted submission:
A, B = map(int, input().split())
S = input()

if S[A] == '-':
    if S[:A].isdecimal() and S[A+1:].isdecimal():
        print('Yes')
        exit()
print('No')
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
A,B,C = list(map(int,input().split()))
print((B-A+1)//C)

Fixed, accepted submission:
A,B,C = list(map(int,input().split()))
print((B//C-(A-1)//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()

from itertools import product

p = product([str(i) for i in range(10)], repeat=3)

ans = 0
for i,j,k in p:
  x = S.find(i)
  if x<0:
    continue
  y = x + S[x+1:].find(j)
  if y<0:
    continue
  z = x + y + S[y+1:].find(k)
  if z<0:
    continue
  ans += 1
print(ans)
    

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

from itertools import product

p = product([str(i) for i in range(10)], repeat=3)

ans = 0
for i,j,k in p:
  x = S.find(i)
  if x<0:
    continue
  y = S[x+1:].find(j)
  if y<0:
    continue
  z = S[x+y+2:].find(k)
  if z<0:
    continue
  #print(i,j,k, S, S[x+1:],S[x+y+2:])
  ans += 1
print(ans)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

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


if a * b % 2 == 0:
  print('Odd')
else:
  print('Even')

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


if a * b % 2 == 1:
  print('Odd')
else:
  print('Even')
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())

price1 = x*a + y*b
price2 = max(x, y)*2*c
if x<=y:
  price3 = x*2*c
  price3 += (y-x)*b
else:
  price3 = y*2*c
  price3 += (y-x)*a

print(min(price1, price2, price3))

Fixed, accepted submission:




a, b, c, x, y = map(int, input().split())

price1 = x * a + y * b
price2 = max(x, y) * 2 * c
price3 = min(x, y) * 2 * c + a * (x - min(x, y)) + b * (y - (min(x, y)))
print(min(price1, price2, price3))
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
  ay = list(map(int,input().split()))
  ab.append(ay)
ans = []
for i in range(n):
  ans.append(0)
for i in range(m):
  for j in range(1,n+1):
    #print(i,j)
    if j in ab[i]:
      ans[j-1] += 1
print(ans)

Fixed, accepted submission:
n,m = [int(i) for i in input().split()]
ab = []
for i in range(m):
  ay = list(map(int,input().split()))
  ab.append(ay)
ans = []
for i in range(n):
  ans.append(0)
for i in range(m):
  for j in range(1,n+1):
    #print(i,j)
    if j in ab[i]:
      ans[j-1] += 1
for i in range(n):
  print(ans[i])
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):
def qsimulator(s, a, b):
	paas = 0
	bpaas = 0
	aflg = True
	bflg = True
	total = a + b
	res = []
	for i in s:
		if i == 'c':
			res.append("No")
		elif i == 'a':
			if aflg and paas <= total:
				paas += 1
				res.append("Yes")
			else:
				aflg = False
				res.append("No")
		else:
			if bflg and paas <= total and bpaas < b:
				paas += 1
				bpaas += 1
				res.append("Yes")
			else:
				bflg = False
				res.append("No")
	return res
n, a, b = map(int, input().split())
s = input()
ans = qsimulator(s, a, b)
for i in ans:
	print(i)

Fixed, accepted submission:
def qsimulator(s, a, b):
	paas = 0
	bpaas = 0
	aflg = True
	bflg = True
	total = a + b
	res = []
	for i in s:
		if i == 'c':
			res.append("No")
		elif i == 'a':
			if aflg and paas < total:
				paas += 1
				res.append("Yes")
			else:
				aflg = False
				res.append("No")
		else:
			if bflg and paas < total and bpaas < b:
				paas += 1
				bpaas += 1
				res.append("Yes")
			else:
				bflg = False
				res.append("No")
	return res
n, a, b = map(int, input().split())
s = input()
ans = qsimulator(s, a, b)
for i in ans:
	print(i)
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())
s = (a+b)*h/2
print(s)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
s = (a+b)*h/2
print(int(s))
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())
if n % 1000 == 0:
  print(0)
else:
  print(1000 - (n % 1000))
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import math
n=int(input().rstrip())
A=list(map(int, input().rstrip().split())) 
A.sort()
work=int()
bestr=int()
def comb(x,y):
    return(math.factorial(x)/(math.factorial(x-y)*math.factorial(y)))
for i in range(n-2):
    if comb(A[n-1],A[i-1])>work:
        work=comb(A[n-1],A[i-1])
        bestr=A[i-1]
print("{0} {1}".format(A[n-1],bestr))

Fixed, accepted submission:
n=int(input().rstrip())
A=list(map(int, input().rstrip().split())) 
A.sort()
work=int()
bestr=int(A[0])
#def comb(x,y):
#    return(math.factorial(x)/(math.factorial(x-y)*math.factorial(y)))

#    if comb(A[n-1],A[i-1])>work:


for i in range(n-2):
    if abs(A[i]-A[n-1]/2)<abs(bestr-A[n-1]/2):
        bestr=A[i]
print("{0} {1}".format(A[n-1],bestr))
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
l=list(map(int,input().split()))
k=int(input())
m=max(l)
l.pop(l.index(m))
print(sum(l)+m**k)

Fixed, accepted submission:
l=list(map(int,input().split()))
k=int(input())
m=max(l)
l.pop(l.index(m))
print(sum(l)+m*(2**k))
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):
A = []
S = input()
S=list(str(S))
for n in S:
 if n == "b":
  A.pop(-1)
 else:
  A.append(n)
print("".join(A))

Fixed, accepted submission:
I = input()

A =''

for n in I:
 if n == '0':
  A += '0'
 elif n == '1':
  A += '1'
 else:
  if len(A) > 0:
   A = A[:-1]


print(A)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
a,b = input(),input()
print("Yes" if a<b else "No")

Fixed, accepted submission:
print("Yes" if sorted(input())<sorted(input(),reverse=1) else "No")
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):
N=map(int,input().split())
S=list(map(str,input().split()))

AC=S.count('AC')
WA=S.count('WA')
TLE=S.count('TLE')
RE=S.count('RE')

print("AC×", end='') 
print(AC)
print("WA×", end='') 
print(WA)
print("TLE×", end='') 
print(TLE)
print("RE×", end='') 
print(RE)

Fixed, accepted submission:
N=int(input())
S=[]
for i in range(0, N):
    val = input()
    S.append(val)
ac=S.count('AC')
wa=S.count('WA')
tle=S.count('TLE')
re=S.count('RE')

print("AC x ", end='') 
print(ac)
print("WA x ", end='') 
print(wa)
print("TLE x ", end='') 
print(tle)
print("RE x ", end='') 
print(re)
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
String = str(input())



## print(char.count(String) & 1)
result = {}
for char in String:
    try:
        result[char] += 1
    except KeyError:
        result[char] = 1

result = list(map(lambda x: x % 2, list(result.values())))
if result == [0] * len(result):
    print('Yes')
else:
    print('No')




Fixed, accepted submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())




result = 0
for i in range(1, N+1):
    if i <= K:
        result += X
    else:
        result += Y
print(result)
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python

a, b = map(int, input().split())
print(a*b)


Fixed, accepted submission:
#!/usr/bin/env python

a, b = map(int, input().split())
print("{} {}".format(a*b, 2*(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):
N = int(input())
str_lis = []
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
  result = input()
  if result == "AC":
    C0 += 1
  elif result == "WA":
    C1 += 1
  elif result == "TLE":
    C2 += 1
  else:
    C3 += 1
    
print("AC × ", C0)
print("WA × ", C1)
print("TLE × ", C2)
print("RE × ", C3)

Fixed, accepted submission:
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
  result = input()
  if result == "AC":
    C0 += 1
  elif result == "WA":
    C1 += 1
  elif result == "TLE":
    C2 += 1
  else:
    C3 += 1
    
print("AC x", C0)
print("WA x", C1)
print("TLE x", C2)
print("RE x", C3)