TnT/CodeNet4Repair huggingface dataset:
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):
a = list(map(int, input().split()))

if(len(a) == 2):
	if(a[0] == 9):
		print('Yes')
	elif(a[1] == 9):
		print('Yes')
	else:
		print('No')

else:
	if(a[0] == 9):
		print('Yes')
	else:
		print('No')

Fixed, accepted submission:
a = list(map(int, list(input())))

if(len(a) == 2):
	if(a[0] == 9):
		print('Yes')
	elif(a[1] == 9):
		print('Yes')
	else:
		print('No')

else:
	if(a[0] == 9):
		print('Yes')
	else:
		print('No')
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())
print(a,b,c)
for i in range(1,10000):
  if a*i%b == c:
    print("YES")
print("NO")

Fixed, accepted submission:
a, b, c = map(int, input().split())
L = []
for i in range(1, b+1):
  L.append(a*i%b)
L2 = list(set(L))
for i in range(len(L2)):
  for k in range(len(L2)):
    if L2[i]+L2[k] == c:
      print("YES")
      quit()
print("NO")
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):
n = int(input())
a = input().split()
b = 0
answer = []
for i in range(n):
    b=0
    if i == 0:
        box = a[i]
        a[i] = 0
    else:
        box = a[i]
        a[i] = int(a[i-1])
        b = int(a[0])
    for j in range(n-1):
        b += abs(int(a[j]) - int(a[j+1]))
    b += abs(int(a[n-1]))
    a[i] = box
    answer.append(b)
print(a)
for k in range(len(answer)):
    print(answer[k])

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total=0

for i in range(1,n+2):
    total+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    ans=total-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])
    print(ans)
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):
s = input()
t = input()

sr = sorted(s)
tr = sorted(t,reverse = True)

print(sr)
print(tr)

if sr < tr:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
s = input()
t = input()

sr = sorted(s)
tr = sorted(t,reverse = True)

#print(sr)
#print(tr)

if sr < tr:
    print('Yes')
else:
    print('No')
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
s=input()
print("YES" if s[0]==s[1]==s[2] or s[1]==s[2]==s[3] else "NO")

Fixed, accepted submission:
s=input()
print("Yes" if s[0]==s[1]==s[2] or s[1]==s[2]==s[3] else "No")
Problem:
Write a program which performs a sequence of commands to a given string $str$. The command is one of:    * print a b: print from the a-th character to the b-th character of $str$   * reverse a b: reverse from the a-th character to the b-th character of $str$   * replace a b p: replace from the a-th character to the b-th character of $str$ with p  Note that the indices of $str$ start with 0.

Incorrect submission (verdict: Wrong Answer):
string = input()
n = int(input())
for i in range(n):
    inp = [x for x in input().split()]
    a = int(inp[1])
    b = int(inp[2])
    if inp[0] == 'print':
        print(string[a-1:b])
    elif inp[0] == 'reverse':
        string = string[:a-1] + string[a-1:b][::-1] +string[b:]
    elif inp[0] == 'replace':
        string = string.replace(string[a-1:b],inp[3])



Fixed, accepted submission:
string = input()
for _ in range(int(input())):
    com = [x for x in input().split()]
    c = com[0]
    a,b = [int(com[i]) for i in range(1,3)]
    if c == 'reverse':
        string = string[:a] + string[a:b+1][::-1] + string[b+1:]
    if c == 'print':
        print(string[a:b+1])
    if c == 'replace':
        string = string[:a] + com[3] + string[b+1:]
Problem:
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.  At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:    * Choose a (connected) rope with a total length of at least L, then untie one of its knots.  Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Incorrect submission (verdict: Wrong Answer):
n,l=map(int,input().split())
arr=list(map(int,input().split()))
psbl=False
pos=0
for i in range(n-1):
    if arr[i]+arr[i+1]>=l:
        psbl=True
        pos=i
        break
print(pos)
if psbl:
    print("Possible")
    for i in range(0,pos):
        print(i+1)
    for i in range(n-2,pos,-1):
        print(i+1)
    print(pos+1)
else:
    print("Impossible")


Fixed, accepted submission:
n,l=map(int,input().split())
arr=list(map(int,input().split()))
psbl=False
pos=0
for i in range(n-1):
    if arr[i]+arr[i+1]>=l:
        psbl=True
        pos=i
        break
if psbl:
    print("Possible")
    for i in range(0,pos):
        print(i+1)
    for i in range(n-2,pos,-1):
        print(i+1)
    print(pos+1)
else:
    print("Impossible")
Problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.  In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.  When activated, each type of robot will operate as follows.    * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.    * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.  Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

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

sum_len = 0
for i in range(len(X)):
    if abs(N-X[i]) < abs(K-X[i]):
        sum_len += abs(N-X[i]) * 2
    else:
        sum_len += abs(K-X[i]) * 2

print(sum_len)

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

sum_len = 0
for i in range(len(X)):
    if X[i] < abs(K-X[i]):
        sum_len += X[i] * 2
    else:
        sum_len += abs(K-X[i]) * 2

print(sum_len)
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 = [input() for _ in range(n)]

numAC = 0
numWA = 0
numTLE = 0
numRE = 0

for i in s:
    if i == "AC":
        numAC += 1
    elif i == "WA":
        numWA += 1
    elif i == "TLE":
        numTLE += 1
    elif i == "RE":
        numRE += 1
        

print("AC × " + str(numAC))
print("WA × " + str(numWA))
print("TLE × " + str(numTLE))
print("RE × " + str(numRE))

Fixed, accepted submission:
n = int(input())
s = [input() for _ in range(n)]

numAC = 0
numWA = 0
numTLE = 0
numRE = 0

for i in s:
    if i == "AC":
        numAC += 1
    elif i == "WA":
        numWA += 1
    elif i == "TLE":
        numTLE += 1
    elif i == "RE":
        numRE += 1
        

print("AC x " + str(numAC))
print("WA x " + str(numWA))
print("TLE x " + str(numTLE))
print("RE x " + str(numRE))
Problem:
N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.

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

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().strip().split()))
ans = 0
for i in range(1, N):
  if A[i] < A[i - 1]:
    ans += A[i - 1] - A[i]
    A[i] = A[i - 1]
print(ans)
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

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


Fixed, accepted submission:
a, b, c = map(int, input().split())
if a < b and b < c:
    print('Yes')
else:
    print('No')
Problem:
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?

Incorrect submission (verdict: Wrong Answer):
N = input()
N.count("2")

Fixed, accepted submission:
N = input()
print(N.count("2"))
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())

ans=N%1000

print(ans)

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

if N%1000==0:
  print(0)
  exit()

elif N>=1000:
  print(1000-N%1000)
 
elif N<1000:
  print(1000-N)
Problem:
Write a program which performs a sequence of commands to a given string $str$. The command is one of:    * print a b: print from the a-th character to the b-th character of $str$   * reverse a b: reverse from the a-th character to the b-th character of $str$   * replace a b p: replace from the a-th character to the b-th character of $str$ with p  Note that the indices of $str$ start with 0.

Incorrect submission (verdict: Wrong Answer):
s = input()
for i in range(int(input())):
    print(s)
    q = input().split()
    op, a, b = q[0], int(q[1]), int(q[2])
    if op == 'print':
        print(s[a : b+1])
    elif op == 'reverse':
        t = s[a : b+1]
        s = s[:a] + t[::-1] + s[b+1:]
    elif op == 'replace':
        s = s[:a] + q[3] + s[b+1:]

Fixed, accepted submission:
s = input()
for i in range(int(input())):
    q = input().split()
    op, a, b = q[0], int(q[1]), int(q[2])
    if op == 'print':
        print(s[a : b+1])
    elif op == 'reverse':
        t = s[a : b+1]
        s = s[:a] + t[::-1] + s[b+1:]
    elif op == 'replace':
        s = s[:a] + q[3] + s[b+1:]
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
a = list(map(int, input().split()))
sum = a[0] + a[1] + a[2]
if sum - a[0] == sum / 2 or sum - a[0] == sum / 2 or sum - a[2] == sum / 2:
    print("Yes")
else:
    print("No")


Fixed, accepted submission:
a = list(map(int, input().split()))
sum = a[0] + a[1] + a[2]
if sum - a[0] == sum / 2 or sum - a[1] == sum / 2 or sum - a[2] == sum / 2:
    print("Yes")
else:
    print("No")
Problem:
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly:    * Insert a letter `x` to any position in s of his choice, including the beginning and end of s.  Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required.

Incorrect submission (verdict: Wrong Answer):
from collections import Counter
S=input()
if S==S[::-1]:
    print(0)
else:
    X=Counter(S)
    if 'x' in X.keys() and len(X.keys())==2:
        cnt=0
        ans=0
        for s in S:
            if s!='x':
                cnt+=1
            else:
                ans+=1
            if cnt==-(-(len(S)-X['x'])//2):
                break
        print(max(ans,X['x']-ans)-min(ans,X['x']-ans))
    else:
        print(0)

Fixed, accepted submission:
S=input()
n=len(S)
l=0
r=n-1
ans=0
while l+1<=r:
    if S[l]=='x' and S[l]!=S[r]:
        ans+=1
        l+=1
    elif S[r]=='x' and S[l]!=S[r]:
        ans+=1
        r-=1
    elif S[l]==S[r]:
        r-=1
        l+=1
    else:
        ans=-1
        break
print(ans)
Problem:
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:    * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.  It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.

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


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

if n>=2 and m>=2:
    n-=2
    m-=2
    print(n*m)
elif n==1 and m==1:
    print(1)
else:
    print(max(n,m)-2)
Problem:
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.     

Incorrect submission (verdict: Wrong Answer):
input_str = input().split(' ')
W = int(input_str[0])
H = int(input_str[0])
x = int(input_str[0])
y = int(input_str[0])
r = int(input_str[0])

print('Yes' if x-r > 0 and x+r < W and y-r > 0 and y+r < H else 'No')

Fixed, accepted submission:
input_str = input().split(' ')
W = int(input_str[0])
H = int(input_str[1])
x = int(input_str[2])
y = int(input_str[3])
r = int(input_str[4])

print('Yes' if x-r >= 0 and x+r <= W and y-r >= 0 and y+r <= H else 'No')
Problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.  In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.  When activated, each type of robot will operate as follows.    * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.    * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.  Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
k = int(input())

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

distance = []

for i in range(n):
  if abs(x[i] - 0) < abs(x[i] - k):
    distance.append(abs((x[i] - 0) * 2))
  else:
    distance.append(abs((x[i] - k) * 2))

print(distance)
print(sum(distance))

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

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

distance = []

for i in range(n):
  if abs(x[i] - 0) < abs(x[i] - k):
    distance.append(abs((x[i] - 0) * 2))
  else:
    distance.append(abs((x[i] - k) * 2))

print(sum(distance))
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())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if s == "AC":
    AC += 1
  elif s == "WA":
    WA += 1
  elif s == "TLE":
    TLE +=1
  else:
    RE += 1
    
print("AC × " + str(AC))
print("WA × " + str(WA))
print("TLE × " + str(TLE))
print("RE × " + str(RE))

Fixed, accepted submission:
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if s == "AC":
    AC += 1
  elif s == "WA":
    WA += 1
  elif s == "TLE":
    TLE +=1
  else:
    RE += 1
    
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))
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(800*N - 200*N//15)

Fixed, accepted submission:
N = int(input())
print(800*N - 200*(N//15))
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Time Limit Exceeded):
def  XYZTriplets():

    num = int(input())
    
    for i in range(num):
        count = 0

        x = 1
        y = 1
        z = 1

        flag = True
        
        while flag == True:
            
            function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                        
            if function == 0:
                if x == y and y == z and z == x:
                    count = count + 1
                
                else:
                    count = count + 3
            
                list_xyz = [x, y, z]
            
                if list_xyz.index(max(list_xyz)) == 0:
                    x = x + 1
                elif list_xyz.index(max(list_xyz)) == 1:
                    y = y + 1
                else:
                    z = z + 1
            
            if function > 0:
                print(count)
        
                break



if __name__ == '__main__':
    XYZTriplets()


Fixed, accepted submission:
import math
import numpy as np

def  XYZTriplets():

    num = int(input())
    
    list_num = []
    
    count = [0]*num
    
    for i in range(1, num+1):
        list_num.append(i)

    for x in range(1, int(math.sqrt(num))):
        for y in range(1, int(math.sqrt(num))):
            for z in range(1, int(math.sqrt(num))):
                
                function = x*x + y*y + z*z + x*y + y*z + z*x
                
                if function <= num and function > 0:
                    count[function-1] = count[function-1] + 1
 
    for i in range(0, num):
        print(count[i])
        

if __name__ == '__main__':
    XYZTriplets()
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())

x = N * (N * 1) // 2

print(x)


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

x = N * (N + 1) // 2

print(x)
Problem:
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.  We have a string T consisting of `P`, `D`, and `?`.  Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.

Incorrect submission (verdict: Wrong Answer):

if __name__ == "__main__":
    T = input()
    ans = ""
    for i in range(len(T)-1):
        if T[i] == '?':
            if T[i+1] == 'D':
                ans += 'P'
            else:
                ans += 'D'
        else:
            ans += T[i]
    if T[-1] == '?':
        ans += 'D'    
    print(ans)


Fixed, accepted submission:
if __name__ == "__main__":
    T = input()
    ans = T
    ans = ans.replace("P?", 'PD')
    ans = ans.replace("??", 'PD')
    ans = ans.replace("?D", 'PD')
    ans = ans.replace("?", 'D')
    print(ans)