TnT/CodeNet4Repair huggingface dataset:
Problem:
You are playing the following game with Joisino.    * Initially, you have a blank sheet of paper.   * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.   * Then, you are asked a question: How many numbers are written on the sheet now?  The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(int(input()) for _ in range(N))
A.sort()
print(A)
count = 0
test = -1
stack = 0
for i in range(N):
    if test != A[i]:
        count += 1
        stack = 1
        test = A[i]
    else:
        if stack == 1:
            count = count - 1
            stack = 0
        else:
            stack = 1
            count += 1
print(count)


Fixed, accepted submission:
N = int(input())
A = list(int(input()) for _ in range(N))
A.sort()
count = 0
test = -1
stack = 0
for i in range(N):
    if test != A[i]:
        count += 1
        stack = 1
        test = A[i]
    else:
        if stack == 1:
            count = count - 1
            stack = 0
        else:
            stack = 1
            count += 1
print(count)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

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

s = s.replace("erase","").replace("eraser","").replace("dream","").replace("dreamer","")

print(s)
if s !="":
    print("No")
else:
    print("Yes")

Fixed, accepted submission:
import re
s = input()

p = re.compile(r'^(dream|dreamer|erase|eraser)*(dream|dreamer|erase|eraser)$')
x = p.search(s)

if x :
    print("YES")
else:
    print("NO")
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
x = []
u = []
Y = 0
for i in range(N):
    s = [i for i in input().split()]
    print(s)
    x.append(float(s[0]))
    u.append(s[1])

    if u[i] == 'BTC':
        Y += x[i]*380000
    else:
        Y += x[i]

print(Y)

Fixed, accepted submission:
N = int(input())
x = []
u = []
Y = 0
for i in range(N):
    s = [i for i in input().split()]
    x.append(float(s[0]))
    u.append(s[1])

    if u[i] == 'BTC':
        Y += x[i]*380000
    else:
        Y += x[i]

print(Y)
Problem:
Takahashi is a user of a site that hosts programming contests.   When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows:    * Let the current rating of the user be a.   * Suppose that the performance of the user in the contest is b.   * Then, the new rating of the user will be the avarage of a and b.  For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.  Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.   Find the performance required to achieve it.

Incorrect submission (verdict: Wrong Answer):
r=float(input())
g=float(input())
print(2*g-r)

Fixed, accepted submission:
r=float(input())
g=float(input())
print(int(2*g-r))
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
def main():
    s = input()
    dream = 0
    erase = 1
    work = []
    temp1 = 0
    temp2 = 0
    kind = -1
    append = work.append
    for c in s:
        if c == 'd':
            if kind != -1:
                append([kind, temp2-temp1])
            kind = dream
            temp1 = temp2
        elif c == 's':
            if kind != -1:
                append([kind, temp2-temp1-3])
            kind = erase
            temp1 = temp2-3
        temp2 += 1
    append([kind, len(s)-temp1])
    result = []
    append = result.append
    for i, j in work:
        if i == dream:
            if j <= 5:
                append("dream")
            else:
                append("dreamer")
        else:
            if j <= 5:
                append("erase")
            else:
                append("eraser")
    result = "Yes" if "".join(result)==s else "No"
    print(result)
main()

Fixed, accepted submission:
def main():
    s = input()
    dream = 0
    erase = 1
    work = []
    temp1 = 0
    temp2 = 0
    kind = -1
    append = work.append
    for c in s:
        if c == 'd':
            if kind != -1:
                append([kind, temp2-temp1])
            kind = dream
            temp1 = temp2
        elif c == 's':
            if kind != -1:
                append([kind, temp2-temp1-3])
            kind = erase
            temp1 = temp2-3
        temp2 += 1
    append([kind, len(s)-temp1])
    result = []
    append = result.append
    for i, j in work:
        if i == dream:
            if j <= 5:
                append("dream")
            else:
                append("dreamer")
        else:
            if j <= 5:
                append("erase")
            else:
                append("eraser")
    result = "YES" if "".join(result)==s else "NO"
    print(result)
main()
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
p = input().split()
s = int(p[0] + p[1] + p[2])
print(s)
if s % 4 == 0:
	print("YES")
else:
	print("NO")

Fixed, accepted submission:
p = input().split()
s = int(p[0])*100 + int(p[1])*10 + int(p[2])

if s % 4 == 0:
	print("YES")
else:
	print("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=int(input())
s=[]
for i in range(n):
  s.append(input())
print("AC"+" × "+str(s.count("AC")))
print("WA"+" × "+str(s.count("WA")))
print("TLE"+" × "+str(s.count("TLE")))
print("RE"+" × "+str(s.count("RE")))


Fixed, accepted submission:
n=int(input())
s=[]
for i in range(n):
  s.append(input())
print("AC"+" x "+str(s.count("AC")))
print("WA"+" x "+str(s.count("WA")))
print("TLE"+" x "+str(s.count("TLE")))
print("RE"+" x "+str(s.count("RE")))
Problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:    * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.  Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

Incorrect submission (verdict: Wrong Answer):
#coding:utf-8
a, b, k = map(int, input().split())

for i in range(0, k):
    if i % 2 == 0:
        b += a // 2
        a /= 2
    else:
        a += b // 2
        b /= 2

print(a, b)

Fixed, accepted submission:
#coding:utf-8
a, b, k = map(int, input().split())

for i in range(0, k):
    if i % 2 == 0:
        b += a // 2
        a = a // 2
    else:
        a += b // 2
        b = b // 2

print(a, b)
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):
S = list(map(str, input()))
if S.sort() == ['a', 'b', 'c']:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
S = list(input())
if len(S) == len(set(S)):
    print('Yes')
else:
    print('No')
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
A = int(input())
B = int(input())
C = int(input())
x = int(input())


la=[]
for a in range(A+1):
    la.append(a)

lb=[]
for b in range(B+1):
    lb.append(b)

lc=[]
for c in range(C+1):
    lc.append(c)

count=0
for i in range(A):
    for j in range(B):
        for p in range(C):
            if(500*la[i]+100*lb[j]+50*lc[p]==x):
                count+=1
print(count)

Fixed, accepted submission:
A = int(input())
B = int(input())
C = int(input())
x = int(input())


count=0
for i in range(A+1):
    for j in range(B+1):
        for p in range(C+1):
          if(10*i+2*j+p==x/50):
          	count+=1
print(count)
Problem:
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.  You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.  However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.  For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

n = int(input())
spot = [int(x) for x in input().split()]
spot = [0] + spot + [0]
print(spot)
cost = 0
for i in range(len(spot)-1):
    cost += abs(spot[i] - spot[i+1])
#print(cost)
change = 0
for k in range(len(spot)-2):
    if (spot[k+1]-spot[k])*(spot[k+2]-spot[k+1]) >= 0:
        change = 0
    else:
        change = 2*min([abs(spot[k+1]-spot[k]),abs(spot[k+2]-spot[k+1])])
    print(cost-change)

Fixed, accepted submission:
# -*- coding: utf-8 -*-

n = int(input())
spot = [int(x) for x in input().split()]
spot = [0] + spot + [0]
cost = 0
for i in range(len(spot)-1):
    cost += abs(spot[i] - spot[i+1])
change = 0
for k in range(len(spot)-2):
    if (spot[k+1]-spot[k])*(spot[k+2]-spot[k+1]) >= 0:
        change = 0
    else:
        change = 2*min([abs(spot[k+1]-spot[k]),abs(spot[k+2]-spot[k+1])])
    print(cost-change)
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):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, readline().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        path[a].append(b)
        path[b].append(a)
    print(path[1])
    print(path[N])
    if set(path[1])&set(path[N]):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Fixed, accepted submission:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, readline().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, readline().split())
        path[a].append(b)
        path[b].append(a)
    if set(path[1])&set(path[N]):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()
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):
# -*- coding:utf-8 -*-

def Selection_Sort(A,n):
    for i in range(n):
        mini = i
        for j in range(i,n): 
            if int(A[j][1]) < int(A[mini][1]):
                mini = j
        if A[i] != A[mini]:
            A[i], A[mini] = A[mini], A[i]
    return A
    
def Bubble_Sort(A, n):
    for i in range(n):
        for j in range(n-1,i,-1):
            if int(A[j][1]) < int(A[j-1][1]):
                A[j], A[j-1] = A[j-1], A[j]
    return A
    
n = int(input())
A = input().strip().split()

print (A[1][1])

B = A[:]
A = Bubble_Sort(A,n)
print (' '.join(A))
print ("Stable")
B =Selection_Sort(B,n)
print (' '.join(B))

if A == B:
    print ("Stable")
else:
    print ("Not stable")

Fixed, accepted submission:
# -*- coding:utf-8 -*-

def Selection_Sort(A,n):
    for i in range(n):
        mini = i
        for j in range(i,n): 
            if int(A[j][1]) < int(A[mini][1]):
                mini = j
        if A[i] != A[mini]:
            A[i], A[mini] = A[mini], A[i]
    return A
    
def Bubble_Sort(A, n):
    for i in range(n):
        for j in range(n-1,i,-1):
            if int(A[j][1]) < int(A[j-1][1]):
                A[j], A[j-1] = A[j-1], A[j]
    return A
    
n = int(input())
A = input().strip().split()

B = A[:]
A = Bubble_Sort(A,n)
print (' '.join(A))
print ("Stable")
B =Selection_Sort(B,n)
print (' '.join(B))

if A == B:
    print ("Stable")
else:
    print ("Not stable")
Problem:
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.  He has very high awareness of safety, and decides to buy two bells, one for each hand.  The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.

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

Fixed, accepted submission:
a, b, c = map(int, input().split())
print(min(a+b, b+c, c+a))
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 = map(int, input().split())
z = float('inf')
n = int(a / b) + 1
flag = False

while True:
    x, y = divmod(n * b + c, a)
    if not x:
        flag = True
        break
    elif y >= z:
        break
    else:
        n += 1
        z = min(z, y)

if flag:
    print('YES')
else:
    print('NO')

Fixed, accepted submission:
a, b, c = map(int, input().split())
n = max(int(b / a), 1)
p = 'NO'
s = set()
r = n * a % b

while r not in s:
    if r == c:
        p = 'YES'
        break
    else:
        s.add(r)
        n += 1
        r = n * a % b
print(p)
Problem:
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows:    * Rating 1-399 : gray   * Rating 400-799 : brown   * Rating 800-1199 : green   * Rating 1200-1599 : cyan   * Rating 1600-1999 : blue   * Rating 2000-2399 : yellow   * Rating 2400-2799 : orange   * Rating 2800-3199 : red  Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.   Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.   Find the minimum and maximum possible numbers of different colors of the users.

Incorrect submission (verdict: Wrong Answer):
N =int(input())
scores = [int(i)//400 for i in input().split()]
d = [0]*10
for s in scores:
    if s > 7:
        s = 8
    d[s] = d[s] + 1
print(d)
if any(d[:8]):
    m = [bool(i) for i in d[:8]].count(True)
else:
    m = 1
M = min(8, m+d[8])
print(m, M)

Fixed, accepted submission:
from collections import Counter
input()
c = Counter([min(int(i)//400,8) for i in input().split()])
lt3200 = [bool(c[i]) for i in range(8)].count(True)
print(max(1, lt3200), lt3200+c[8])
Problem:
In programming, hexadecimal notation is often used.  In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.  In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`.  When X and Y are seen as hexadecimal numbers, which is larger?

Incorrect submission (verdict: Wrong Answer):
x,y = input().split()
if x>y: print(x)
else: print(y)

Fixed, accepted submission:
x,y = input().split()
if x>y: print('>')
elif x<y: print('<')
else: print('=')
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 = 60
x = 800 * N
y = 200 * (N // 15)

print(x - y)

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

print(int(x - y))
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
import itertools

N, K = [int(s) for s in input().split()]
D = [int(s) for s in input().split()]
U = [str(n) for n in range(10) if n not in D]

ret = N * 10
for v in [int(''.join(T)) for T in itertools.product(U, repeat=4)]:
    print(v)
    if N <= v:
        ret = min(ret, v)
print(ret)


Fixed, accepted submission:
from functools import reduce

N, _ = [int(s) for s in input().split()]
D = [s for s in input().split()]

R = N
while True:
    if reduce(lambda x, y: x and y, [s not in D for s in list(str(R))]):
        break
    R += 1
print(R)
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 = map(int,input().split())
aa = [input() for _ in range(h)]

print(aa)

for i in range(h+2):
    if i == 0 or i == h+1:
        print('#'*(w+2))
    else:
        print('#'+aa[i-1]+'#')


Fixed, accepted submission:
h,w = map(int,input().split())
aa = [input() for _ in range(h)]


for i in range(h+2):
    if i == 0 or i == h+1:
        print('#'*(w+2))
    else:
        print('#'+aa[i-1]+'#')
Problem:
Your task is to perform a simple table calculation.  Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.

Incorrect submission (verdict: Wrong Answer):
r,c=[int(x) for x in input().split()]
s_row=[0 for x in range(c+1)]
for i in range(r):
    row=[int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row=[x+y for x,y in zip(s_row,row)]

Fixed, accepted submission:
r,c=[int(x) for x in input().split()]
s_row=[0 for x in range(c+1)]
for i in range(r):
    row=[int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row=[x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))
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 = input().split()

if int(a[0])<int(a[2]) and int(a[0])+int(a[1])>int(a[2]):
  print("yes")
else:
  print("no")

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

if int(a[0])<=int(a[2]) and int(a[0])+int(a[1])>=int(a[2]):
  print("YES")
else:
  print("NO")
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())
ans = 0
for i in range(1, n+1):
    if a <=  sum([int(c) for c in str(i)]) <= b:
        ans += 1
print(ans)


Fixed, accepted submission:
n, a, b= map(int, input().split())
ans = 0
for i in range(1, n+1):
    if a <=  sum([int(c) for c in str(i)]) <= b:
        ans += i
print(ans)