TnT/CodeNet4Repair huggingface dataset:
Problem:
Write a program which reads a list of student test scores and evaluates the performance for each student.  The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1.  The final performance of a student is evaluated by the following procedure:    * If the student does not take the midterm or final examination, the student's grade shall be F.   * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.   * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.   * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.   * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.   * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.

Incorrect submission (verdict: Wrong Answer):
scores = []
while True:
    score = list(map(int, input().split()))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        scores.append(score)
        
print(scores)
for i in scores:
    mid_exam = i[0]
    final_exam = i[1]
    re_exam = i[2]
    total = i[0] + i[1]
    if mid_exam == -1 or final_exam == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total in range(65, 80):
        print("B")
    elif total in range(50, 65):
        print("C")
    elif total < 30:
        print("F")
    elif total in range(30, 50):
        if re_exam >= 50:
            print("C")
        else:
            print("D")

Fixed, accepted submission:
scores = []
while True:
    score = list(map(int, input().split()))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        scores.append(score)

for i in scores:
    mid_exam = i[0]
    final_exam = i[1]
    re_exam = i[2]
    total = i[0] + i[1]
    if mid_exam == -1 or final_exam == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total in range(65, 80):
        print("B")
    elif total in range(50, 65):
        print("C")
    elif 30 <= total < 50:
        if re_exam >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

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

print(a.count == "1")

Fixed, accepted submission:
a=input()

print(a.count("1"))
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):
n = int(input())
a = [0]*n
a = list(map(int, input().split()))

a.sort()
hoge = a[n-1] / 2 - a[0]
ans = 0
for i in range(n-1):
    print(abs(a[n-1] / 2 - a[i+1]))
    if abs(a[n-1] / 2 - a[i+1]) > hoge:
        ans = i
        break
    else:
        hoge = abs(a[n-1] / 2 - a[i+1])

print(a[n-1], a[ans])

Fixed, accepted submission:

n = int(input())
a = [0]*n
a = list(map(int, input().split()))

a.sort()
hoge = a[n-1] / 2 - a[0]
ans = 0
for i in range(n-1):
    if abs(a[n-1] / 2 - a[i+1]) > hoge:
        ans = i
        break
    else:
        hoge = abs(a[n-1] / 2 - a[i+1])

print(a[n-1], a[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()

for i in range(len(S)) :  
    if i + len(T) >= len(S) :
        print('UNRESTORABLE')
        break
    for j, t in enumerate(T) :
        if S[i + j] != t and S[i + j] != '?':
            break
    else :
        for s in S[:i] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print(T, end='')
        for s in S[i + len(T) + 1:] :
            print(s, end='')
        print('')
        break
else :
    print('UNRESTORABLE')

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

ans = []
for l in range(len(S) - len(T) + 1):
    U = S[l: l + len(T)]
    for u, t in zip(U, T):
        if u == '?':
            continue
        if u != t:
            break
    else:
        ans.append((S[:l] + T + S[l + len(T):]).replace('?', 'a'))

ans.sort()
print(ans[0] if len(ans) > 0 else 'UNRESTORABLE')
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Incorrect submission (verdict: Wrong Answer):
X= input('')
Y=0
Z=0
for i in range(len(X)):
    c = X[i]
    if c == "o" :
        Y += 1
    elif c == 'x' :
        Z += 1
if Z >= 8 :
    print("NO")
elif Y >= 8 :
    print("YES")

Fixed, accepted submission:
X= input('')
Y=0
Z=0
for i in range(len(X)):
    c = X[i]
    if c == "o" :
        Y += 1
    elif c == 'x' :
        Z += 1
if Z >= 8 :
    print("NO")
else :
    print("YES")
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:
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())
jud = [0,0,0,0]
for i in range(N):
  s = str(input())
  if(s == "AC"):
    jud[0]+=1
  elif(s == "WA"):
    jud[1] += 1
  elif(s == "TLE"):
    jud[2]+=1
  else:
    jud[3]+=1
print("AC x" +str(jud[0]))
print("WA x" +str(jud[1]))
print("TLE x" +str(jud[2]))
print("RE x" + str(jud[3]))
  

Fixed, accepted submission:
N = int(input())
jud = [0,0,0,0]
for i in range(N):
  s = str(input())
  if(s == "AC"):
    jud[0]+=1
  elif(s == "WA"):
    jud[1] += 1
  elif(s == "TLE"):
    jud[2]+=1
  else:
    jud[3]+=1
print("AC x " +str(jud[0]))
print("WA x " +str(jud[1]))
print("TLE x " +str(jud[2]))
print("RE x " + str(jud[3]))
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()

while 'eraser' in S:
    S = S.replace('eraser','')

while 'erase' in S:
    S = S.replace('erase','')

while 'dreamer' in S:
    S = S.replace('dreamer','')

while 'dream' in S:
    S = S.replace('dream','')

if S == '':
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline



def main():
    S = input().rstrip()

    words = ['dream','dreamer','erase','eraser']

    res = 'YES'

    pre = S
    now = S

    while True:
        for i in range(4):
            word = words[i]
            N = len(word)
            M = len(now)
            if N <= M:
                r = now[M-N:]
                if r == word:
                    now = now[:M-N]
        if now == '':
            break
        elif now == pre:
            res = 'NO'
            break
        else:
            pre = now

    print(res)



main()
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(1000-N)

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

if not N%1000==0:
    p = N//1000+1
else:
    p = N//1000
print(p*1000-N)
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())

l = []
for i in range(N):
    text = input()
    l.append(text)

print("AC" + " x " + str(l.count("AC")))
print("AC" + " x " + str(l.count("WA")))
print("TLE" + " x " + str(l.count("TLE")))
print("RE" + " x " + str(l.count("RE")))

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

l = []
for i in range(N):
    text = input()
    l.append(text)

print("AC" + " x " + str(l.count("AC")))
print("WA" + " x " + str(l.count("WA")))
print("TLE" + " x " + str(l.count("TLE")))
print("RE" + " x " + str(l.count("RE")))
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, B, C, X = [int(input()) for i in range(4)]
count = 0
for a in range(A):
    for b in range(B):
        for c in range(C):
            if 500*a+100*b+50*c==X:
                count += 1
print(count)

Fixed, accepted submission:
A, B, C, X = [int(input()) for i in range(4)]
print([500*a+100*b+50*c for a in range(A+1) for b in range(B+1) for c in range(C+1)].count(X))
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
    sum = s.count(word_list[i])
    sum -= t.count(word_list[i])
else:
    money_list.append(sum)

money_list.sort()
if money_list[0] < 0:
    print(0)
else:
    print(money_list[0])


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

M = int(input())
t = []
for i in range(M):
    t.append(input())

money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
    sum = s.count(word_list[i])
    sum -= t.count(word_list[i])
    if sum < 0:
        sum = 0
    money_list.append(sum)

money_list.sort(reverse = True)
print(money_list[0])
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):
number = list(map(int,input().split()))

min = min(number)

number.remove(min)

print(number[0] + number[1])

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

max = max(number)

number.remove(max)

print(number[0] + number[1])
Problem:
Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i.  At the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the following operation:    * Choose a vertex v that contains one or more coins, and remove all the coins from v.   * Then, move each coin remaining on the tree to the vertex that is nearest to v among the adjacent vertices of the coin's current vertex.  The player who becomes unable to play, loses the game. That is, the player who takes his turn when there is no coin remaining on the tree, loses the game. Determine the winner of the game when both players play optimally.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
def dijkstra(s):
  D = [-1] * N
  D[s] = s
  Q = [0] * N
  Q[0] = s
  pos = 1
  for i in range(N):
    v = Q[i]
    for adj in E[v]:
      if D[adj] >= 0:
        continue
      Q[pos] = adj
      pos += 1
      D[adj] = D[v] + 1
  return D
D = dijkstra(0)
_, s = max([[D[i], i] for i in range(N)])
D = dijkstra(s)
L = max(D)
print('First' if L % 3 != 1 else 'Second')

Fixed, accepted submission:
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
def dijkstra(s):
  D = [-1] * N
  D[s] = 0
  Q = [0] * N
  Q[0] = s
  pos = 1
  for i in range(N):
    v = Q[i]
    for adj in E[v]:
      if D[adj] >= 0:
        continue
      Q[pos] = adj
      pos += 1
      D[adj] = D[v] + 1
  return D
D = dijkstra(0)
_, s = max([[D[i], i] for i in range(N)])
D = dijkstra(s)
L = max(D)
print('First' if L % 3 != 1 else 'Second')
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    for i in range(2 ** l):
        binary = bi(i, l)
        tot = int(inp[0])
        for j in range(l):
            if binary[j] == "1":
                tot += int(inp[j+1])
            else:
                tot -= int(inp[j+1])
        print(tot)
        if tot == 7:
            return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])

inp = input()

print(solve(str(inp)))


Fixed, accepted submission:
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    for i in range(2 ** l):
        binary = bi(i, l)
        tot = int(inp[0])
        for j in range(l):
            if binary[j] == "1":
                tot += int(inp[j+1])
            else:
                tot -= int(inp[j+1])
        if tot == 7:
            return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])

inp = input()

print(solve(str(inp)))
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):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    a.insert(n, 0)
    a.insert(0, 0)

    print(a)

    all_cost = 0
    for i in range(1, n+2):
        all_cost += abs(a[i] - a[i-1])

    for i in range(1, n+1):
        diff_cost = abs(a[i+1] - a[i-1]) - ( abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) )
        print(all_cost + diff_cost)

if __name__ == '__main__':
    main()


Fixed, accepted submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    a.insert(n, 0)
    a.insert(0, 0)

    all_cost = 0
    for i in range(1, n+2):
        all_cost += abs(a[i] - a[i-1])

    for i in range(1, n+1):
        diff_cost = abs(a[i+1] - a[i-1]) - ( abs(a[i+1] - a[i]) + abs(a[i] - a[i-1]) )
        print(all_cost + diff_cost)

if __name__ == '__main__':
    main()
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
# Your code here!

A, B, C = list(map(int, input().split()))
if A < B:
    if A < C and C < B:
        print("yes")
    else:
        print("no")

if A > B:
    if A > C and C > B:
        print("yes")
    else:
        print("no")
        

Fixed, accepted submission:
A, B, C = list(map(int, input().split()))
if A < B:
    if A < C and C < B:
        print("Yes")
    else:
        print("No")
elif A > B:
    if A > C and C > B:
        print("Yes")
    else:
        print("No")
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
s = input()
n = len(s)
s = s[:-2]
for _ in range(n):
  n = len(s)
  m = int(n/2)
  if s[:m] == s[m:]:
    print(s)
    break
  else:
    s = s[:-2]

Fixed, accepted submission:
s = input()
n = len(s)
s = s[:-2]
for _ in range(n):
  n = len(s)
  m = int(n/2)
  if s[:m] == s[m:]:
    print(len(s))
    break
  else:
    s = s[:-2]
Problem:
You are visiting a large electronics store to buy a refrigerator and a microwave.  The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen.  You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.  You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Incorrect submission (verdict: Wrong Answer):
S = input()
for i in range(6):
    x = 'hi'*i
    if S == x:
        print('Yes')
        break;
else:
    print('No')


Fixed, accepted submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = min(a) + min(b)
for S in range(M):
    x, y, c = map(int, input().split())
    r = min(r, a[x-1] + b[y-1] - c)
print(r)
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

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

if(b<a):
    print("delicious")
elif(b-a>x):
    print("safe")
else:
    print("dangerous")


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

if(b<=a):
    print("delicious")
elif(b-a<=x):
    print("safe")
else:
    print("dangerous")
Problem:
Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_

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

x=a%b

while x>0:
	a=b
	x=a%x
	b=x

print(a)


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

x=a%b

while x>0:
	a=b
	b=x
	x=a%b

print(b)