TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Incorrect submission (verdict: Wrong Answer):
A, B, C = map(int, input().split())
if max(A,B,C)*3%2 == (A+B+C)%2:
  print((max(A,B,C)*3-(A+B+C))/2)
else:
  print((max(A,B,C)*3+3-(A+B+C))/2)

  

  
                                            


Fixed, accepted submission:
A, B, C = map(int, input().split())
if max(A,B,C)*3%2 == (A+B+C)%2:
  print(int((max(A,B,C)*3-(A+B+C))/2))
else:
  print(int((max(A,B,C)*3+3-(A+B+C))/2))
Problem:
会津学園高等学校では、毎年学園祭をおこなっています。その中でも一番人気はお化け屋敷です。一番人気の理由は、お化け屋敷をおこなうクラスが 1クラスや 2クラスではなく、9クラスがお化け屋敷をおこなうことです。それぞれが工夫することより、それぞれが個性的なお化け屋敷になっています。そのため、最近では近隣から多くの来場者が訪れます。  そこで、学園祭実行委員会では、お化け屋敷の入場料金を下表のように校内で統一し、これにもとづき各クラスごとに入場者総数と収入の集計をおこなうことにしました。  入場料金表(入場者 1人あたりの入場料)                  午前   午後 200円   300円   各クラス毎の午前と午後の入場者数を入力とし、各クラス毎の入場者総数及び収入の一覧表を作成するプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(str,input().split())
print(a,int(b)+int(c),int(b)*200+int(c)*300)


Fixed, accepted submission:
for i in range(9):
  n,a,b = list(input().split())
  x = int(a) + int(b)
  y = int(a)*200 + int(b)*300
  print(f"{n} {x} {y}")
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):
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

b = []
for ai in a:
    b.append(ai)
    b = b[::-1]
print(b)


Fixed, accepted submission:
import sys
from collections import deque

input = sys.stdin.readline


n = int(input())
a = input().split()

b = deque([])
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b = list(b)[::-1]
print(' '.join(b))
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
n,m = map(int,input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        c[b] == True
    if b == n:
        d[a] = True
for i in range(n):
    if c[i] and d[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed, accepted submission:
n,m = map(int,input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        c[b] = True
    if b == n:
        d[a] = True
for i in range(n):
    if c[i] and d[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a, b, c = [int(i) for i in input().split()]
for i in range(1, b+1):
    if a*i % b == c:
        print("YES")
        break
    else:
        print("NO")



Fixed, accepted submission:
a, b, c = [int(i) for i in input().split()]
for i in range(1, b+1):
    if a*i % b == c:
        print("YES")
        break
else: print("NO")
Problem:
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i.  The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.  When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.  What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
print(A)
ans=0
for i in range(len(A)-1):
    ans+=A[i]
        
print(ans)

Fixed, accepted submission:
from collections import deque
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
conf=[A[0]]
ans=0
con=deque(conf)
A.pop(0)


for elem in A:
    ans+=con.popleft()
    
    for _ in range(2):
        con.append(elem)

print(ans)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
x=2

print("x**2")


Fixed, accepted submission:
print(int(input())**3)
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()
result = "UNRESTORABLE"
b = True
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        print("%d, %d" % (i, j))
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == len(T) - 1:
            s = (S[:i] + T + S[i + len(T):]).replace("?", "a")
            if b or s < result:
                result = s
                b = False
print(result)


Fixed, accepted submission:
S = input()
T = input()
result = "UNRESTORABLE"
b = True
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == len(T) - 1:
            s = (S[:i] + T + S[i + len(T):]).replace("?", "a")
            if b or s < result:
                result = s
                b = False
print(result)
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(a[0] - w))
else:
  print(max(a[-1] - w, 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(a[0] - w))
else:
  print(max(abs(a[-1] - w), abs(a[-1] - a[-2])))
Problem:
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.  Integers M_1, D_1, M_2, and D_2 will be given as input.   It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.   Determine whether the date 2019-M_1-D_1 is the last day of a month.

Incorrect submission (verdict: Wrong Answer):
a = input().split()
c = input().split
if a != c:
	print(1)
else:
	print(0)

Fixed, accepted submission:
a = input().split()
c = input().split()
if a[0] != c[0]:
	print(1)
else:
	print(0)
Problem:
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.  Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:                 BubbleSort(C) 1 for i = 0 to C.length-1 2     for j = C.length-1 downto i+1 3         if C[j].value < C[j-1].value 4             swap C[j] and C[j-1]                 SelectionSort(C) 1 for i = 0 to C.length-1 2     mini = i 3     for j = i to C.length-1 4         if C[j].value < C[mini].value 5             mini = j 6     swap C[i] and C[mini]   Note that, indices for array elements are based on 0-origin.  For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).

Incorrect submission (verdict: Wrong Answer):
def BubbleSort(C, N):

    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j][1] < C[j-1][1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C

def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j][1] < C[minj][1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

def isStable(C1, C2, N):
    if C1 != C2:
        return "Stable"
    return "Not stable"

Num = int(input())
Cards = [x for x in input().split()]
card1 = BubbleSort(list(Cards), Num)
card2 = SelectionSort(list(Cards), Num)

print(" ".join(card1))
print(isStable(card1, card1, Num))
print(" ".join(card2))
print(isStable(card1, card2, Num))



Fixed, accepted submission:
def BubbleSort(C, N):

    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j][1] < C[j-1][1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C

def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j][1] < C[minj][1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

def isStable(C1, C2, N):
    if C1 != C2:
        return "Not stable"
    return "Stable"

Num = int(input())
Cards = [x for x in input().split()]
card1 = BubbleSort(list(Cards), Num)
card2 = SelectionSort(list(Cards), Num)

print(" ".join(card1))
print(isStable(card1, card1, Num))
print(" ".join(card2))
print(isStable(card1, card2, Num))
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
a,b,x = map(int,input().split())
print("Yes" if (a + b >= x) and (x >= a) else "No")

Fixed, accepted submission:
a,b,x = map(int,input().split())
print("YES" if (a + b >= x) and (x >= a) else "NO")
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
a=input().strip().split(" ")

b=[int(i) for i in a]

A=abs(b[0]-b[1])
B=abs(b[0]-b[2])

if(A>B):
    print(B)
else:
    print(A)


Fixed, accepted submission:
a=input().strip().split(" ")

b=[int(i) for i in a]

A=abs(b[0]-b[1])
B=abs(b[0]-b[2])

if(A>B):
    print("B")
else:
    print("A")
Problem:
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples.  Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows:    * _Move_ : When at town i (i < N), move to town i + 1.   * _Merchandise_ : Buy or sell an arbitrary number of apples at the current town. Here, it is assumed that one apple can always be bought and sold for A_i yen (the currency of Japan) at town i (1 ≦ i ≦ N), where A_i are distinct integers. Also, you can assume that he has an infinite supply of money.  For some reason, there is a constraint on merchandising apple during the travel: the sum of the number of apples bought and the number of apples sold during the whole travel, must be at most T. (Note that a single apple can be counted in both.)  During the travel, Takahashi will perform actions so that the _profit_ of the travel is maximized. Here, the profit of the travel is the amount of money that is gained by selling apples, minus the amount of money that is spent on buying apples. Note that we are not interested in apples in his possession at the end of the travel.  Aoki, a business rival of Takahashi, wants to trouble Takahashi by manipulating the market price of apples. Prior to the beginning of Takahashi's travel, Aoki can change A_i into another arbitrary non-negative integer A_i' for any town i, any number of times. The cost of performing this operation is |A_i - A_i'|. After performing this operation, different towns may have equal values of A_i.  Aoki's objective is to decrease Takahashi's expected profit by at least 1 yen. Find the minimum total cost to achieve it. You may assume that Takahashi's expected profit is initially at least 1 yen.

Incorrect submission (verdict: Wrong Answer):

N,T = map(int, input().split())
As = list(map(int, input().split()))
AsR = As[::-1]
mxs = []
mx = 0
ind = 0
for i, a in enumerate(AsR):
    if a > mx:
        mx = a
        ind = N-i-1
    mxs.append((mx,ind))
pairs = []
for a,mx in zip(As,mxs[::-1]):
    print(mx[0]-a,mx[1])
    pairs.append((mx[0]-a,mx[1]))
pairs.sort(reverse=True)
mx = pairs[0][0]
from collections import defaultdict
ans = set()
for x, i in pairs:
    if x != mx:break
    ans.add(i)
print(len(ans))

Fixed, accepted submission:


N,T = map(int, input().split())
As = list(map(int, input().split()))
AsR = As[::-1]
mxs = []
mx = 0
ind = 0
for i, a in enumerate(AsR):
    if a > mx:
        mx = a
        ind = N-i-1
    mxs.append((mx,ind))
pairs = []
for a,mx in zip(As,mxs[::-1]):
    # print(mx[0]-a,mx[1])
    pairs.append((mx[0]-a,mx[1]))
pairs.sort(reverse=True)
mx = pairs[0][0]
from collections import defaultdict
ans = set()
for x, i in pairs:
    if x != mx:break
    ans.add(i)
print(len(ans))
Problem:
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode:                 BubbleSort(A) 1 for i = 0 to A.length-1 2     for j = A.length-1 downto i+1 3         if A[j] < A[j-1] 4             swap A[j] and A[j-1]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 4 of the pseudocode.

Incorrect submission (verdict: Wrong Answer):
def bubbleSort(A, N):
    t = 0
    flag = 0
    while flag == 0:
        flag = 1
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 0
                t += 1
n = int(input())
a = [int(i) for i in input().split()]

print(bubbleSort(a, n))

Fixed, accepted submission:
def bubbleSort(A, N):
    s = 0
    flag = 0
    while flag == 0:
        flag = 1
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 0
                s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

n = int(input())
a = [int(i) for i in input().split()]

bubbleSort(a, n)
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
s=input()
a=s.index("A")
b=s.rfind("z")
print(s[a:b+1])

Fixed, accepted submission:
s=input()
a=s.index("A")
b=s.rfind("Z")
print(len(s[a:b+1]))
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())
res=[]
for i in range(n):
    res.append(input())

from collections import defaultdict
cnt=defaultdict(int)
cnt["AC"]=0
cnt["TLE"]=0
cnt["WA"]=0
cnt["RE"]=0
for i in res:
    cnt[i]+=1
for i in cnt.items():
    print(i[0],"x",i[1])

Fixed, accepted submission:
n=int(input())
res=[]
for i in range(n):
    res.append(input())

from collections import defaultdict
cnt=defaultdict(int)
cnt["AC"]=0
cnt["TLE"]=0
cnt["WA"]=0
cnt["RE"]=0
for i in res:
    cnt[i]+=1
for i in ["AC","WA","TLE","RE"]:
    print(i,"x",cnt[i])
Problem:
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.  You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.

Incorrect submission (verdict: Wrong Answer):
O = input()
E = input()

A = [E, O]
for i in range(len(O)+len(E)):
    j, r = divmod(i, 2)
    print(A[1-r],end="")
print()

Fixed, accepted submission:
O = list(input())
E = list(input())

if len(O) > len(E):
    E.append("")

print("".join(o+e for o, e in zip(O, E)))
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
s = input()
cnt = 0
for i in range(3):
    if s[i] == '1':
        cnt += 1

print(cnt)

Fixed, accepted submission:
n, a, b = map(int, input().split())
if n*a > b:
    print(b)

else:
    print(n*a)
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
n, a, b = map(int, input().split())
sumdict = dict()
for i in range(1, 37) :
    sumdict[i] = []
for i in range(1, n) :
    sumofi = sum([int(k) for k in list(str(i))])
    sumdict[sumofi] += [i]
ans = 0
for i in range(a, b + 1) :
    ans += sum(sumdict[i])
print(ans)

Fixed, accepted submission:
n, a, b = map(int, input().split())
sumdict = dict()
for i in range(1, 37) :
    sumdict[i] = [0]
for i in range(1, n + 1) :
    sumofi = sum([int(k) for k in list(str(i))])
    sumdict[sumofi] += [i]
ans = 0
for i in range(a, b + 1) :
    ans += sum(sumdict[i])
print(ans)
Problem:
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.  Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:                 BubbleSort(C) 1 for i = 0 to C.length-1 2     for j = C.length-1 downto i+1 3         if C[j].value < C[j-1].value 4             swap C[j] and C[j-1]                 SelectionSort(C) 1 for i = 0 to C.length-1 2     mini = i 3     for j = i to C.length-1 4         if C[j].value < C[mini].value 5             mini = j 6     swap C[i] and C[mini]   Note that, indices for array elements are based on 0-origin.  For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).

Incorrect submission (verdict: Wrong Answer):
n = int(input())
*s1, = input().split()
s2 = s1[:]

def bubbleSort(s):
    flag = True
    while flag:
        flag = False
        for i in range(n-1):
            if int(s[i][1]) > int(s[i+1][1]):
                s[i],s[i+1] = s[i+1],s[i]
                flag = True
    return s

def selectionSort(s):
    for i in range(n):
        minj = i
        for j in range(i+1,n):
            if int(s[minj][1]) > int(s[j][1]):
                minj = j
        s[i],s[minj] = s[minj],s[i]
    return s

print(' '.join(bubbleSort(s1)))
print("Stable")
print(' '.join(selectionSort(s2)))
if s1 == s2:
    print("Stable")
else:
    print("Not Stable")



Fixed, accepted submission:
n = int(input())
a = [i for i in input().split()]
b = [a[i] for i in range(n)]
def bubbleSort(A):
    for i in range(n):
        for j in range(i+1,n)[::-1]:
            if int(A[j][1]) < int(A[j-1][1]):
                A[j], A[j-1] = A[j-1], A[j]
    return A

def selectionSort(A):
    for i in range(n):
        minj = i
        for j in range(i,n):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        A[i], A[minj] = A[minj], A[i]
    return A

bubbleSort(a)
selectionSort(b)

print(' '.join(a))
print("Stable")
print(' '.join(b))
if a == b:
    print("Stable")
else:
    print("Not stable")
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):
N = int(input())
print(N * 800 - (N % 15) * 200)

Fixed, accepted submission:
N = int(input())
print(N * 800 - (N // 15) * 200)