TnT/CodeNet4Repair huggingface dataset:
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

Incorrect submission (verdict: Wrong Answer):
import sys
from collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    S = readline().decode('utf-8')
    L = len(S)
    d = deque()
    for i in range(L):
        if S[i]=='0':
            d.append(0)
        elif S[i]=='1':
            d.append(1)
        else:
            if len(d)!=0:
                d.pop()
    print(''.join(map(str,d)))



if __name__ == '__main__':
    main()

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



def main():
    S = input()
    L = len(S)
    d = deque()
    for i in range(L):
        if S[i]=='0':
            d.append(0)
        elif S[i]=='1':
            d.append(1)
        else:
            if len(d)!=0:
                d.pop()
    print(''.join(map(str,d)))



if __name__ == '__main__':
    main()
Problem:
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.  We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.  At most how many people can sit on the seat?

Incorrect submission (verdict: Wrong Answer):
X, Y, Z = map(int, input().split())
print((X-Z)%(Y+Z))

Fixed, accepted submission:
X, Y, Z = map(int, input().split())
print((X-Z)//(Y+Z))
Problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:    * The graph is simple and connected.   * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.  It can be proved that at least one such graph exists under the constraints of this problem.

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

g = [[1] * (n + 1) for _ in range(n + 1)]

if n % 2:
    for i in range(1, n + 1):
        j = n - i
        g[i][j] = 0
        g[j][i] = 0

else:
    for i in range(1, n + 1):
        j = n + 1 - i
        g[i][j] = 0
        g[j][i] = 0

for i, row in enumerate(g[1:], 1):
    for j, bl in enumerate(row[i+1:], i+1):
        if bl:
            print(i, j)


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

g = [[1] * (n + 1) for _ in range(n + 1)]

if n % 2:
    for i in range(1, n + 1):
        j = n - i
        g[i][j] = 0
        g[j][i] = 0

else:
    for i in range(1, n + 1):
        j = n + 1 - i
        g[i][j] = 0
        g[j][i] = 0

ans = []
for i, row in enumerate(g[1:], 1):
    for j, bl in enumerate(row[i+1:], i+1):
        if bl:
            ans.append((i, j))

print(len(ans))
for i, j in ans:
    print(i, j)
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

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

if n <= k:
    print(n * x)
else:
    print((n * x) + ((n - k) * y))

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

if n <= k:
    print(n * x)
else:
    print((k * x) + ((n - k) * y))
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

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

Fixed, accepted submission:
a, b, c = map(int, input().split())
print('Yes' if a + b >= c else 'No')
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):


def Range():
    a,b,c = list(map(int,input().split()))
    if a<b<c:
        print("YES")
    else:
        print("NO")


Range()

Fixed, accepted submission:
def Range():
    a,b,c = list(map(int,input().split()))
    if a<b<c:
        print("Yes")
    else:
        print("No")


Range()
Problem:
Takahashi is organizing a party.  At the party, each guest will receive one or more snack pieces.  Takahashi predicts that the number of guests at this party will be A or B.  Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.  We assume that a piece cannot be divided and distributed to multiple guests.

Incorrect submission (verdict: Wrong Answer):
A, B = [int(i) for i in input().split(' ')]

if A>B:
	A, B = B, A


def eculidian_algo(A,B):
	while True:
		q = A//B
		r = A%B
		if r==0:
  			break
		else:
			A,B=B,r
	return B
  
lcd = eculidian_algo(A,B)
gcm = A*B / lcd
print(gcm)

Fixed, accepted submission:
A, B = [int(i) for i in input().split(' ')]

def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return x/gcd(x, y)*y
  
print(int(lcm(A,B)))
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):
import sys

for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('E')

Fixed, accepted submission:
import sys

for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

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

    _set = set()
    if a <= c and b >= c: _set.add(c)
    if c // 2 < b:
        b = c // 2
    if c % 2 == 0:
        _set = _set | set(range(a, b+1))
    else:
        if a % 2 == 0:
            _set = _set | set(range(a+1, b+1, 2))
        else:
            _set = _set | set(range(a, b+1, 2))
            
    return sum(map(lambda x: c % x == 0, _set))

main()

Fixed, accepted submission:
def main():
    a, b, c = map(int,input().split())
 
    _set = set()
    if a <= c and b >= c: _set.add(c)
    if c // 2 < b:
        b = c // 2
    if c % 2 == 0:
        _set = _set | set(range(a, b+1))
    else:
        if a % 2 == 0:
            _set = _set | set(range(a+1, b+1, 2))
        else:
            _set = _set | set(range(a, b+1, 2))
             
    print(sum(map(lambda x: c % x == 0, _set)))
 
main()
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
input_ = int(input())

ex_ = input_ / (1.08)

if (ex_ - int(ex_)) > 0.1:
  print(round(ex_))
else:
  print(":(")

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

for i in range(input_):
  if int((i+1)*1.08) == input_:
    print(i+1)
    break
else:
  print(":(")
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for i in range(0, N):
    t1, x1, y1 = map(int, input().split())
    indicator = abs(x1-x0)+abs(y1-y0)-(t1-t0)
    if indicator>0 or indicator%2==1:
        print("NO")
        break
    elif i==N-1:
        print("YES")
        break
    t0 = t1
    x0 = x1
    y0 = y1


Fixed, accepted submission:
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for i in range(0, N):
    t1, x1, y1 = map(int, input().split())
    id = (t1-t0)-abs(x1-x0)-abs(y1-y0)
    if id<0 or id%2==1:
        print("No")
        break
    elif i==N-1:
        print("Yes")
    t0 = t1
    x0 = x1
    y0 = y1
Problem:
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains.  Write a program which prints heights of the top three mountains in descending order.

Incorrect submission (verdict: Wrong Answer):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	mountains = []
	for i in range(3):
		mountains.append(int(input()))
	
	mountains = sorted(mountains, reverse = True)

	for i in range(3):
		print(mountains[i])


if __name__ == '__main__':
    main()

Fixed, accepted submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	mountains = []
	for i in range(10):
		mountains.append(int(input()))
	
	mountains = sorted(mountains, reverse = True)

	for i in range(3):
		print(mountains[i])


if __name__ == '__main__':
    main()
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):
S = input()
count = len(S)-1
for i in range(2**count):
  sign=['-']*count
  for j in range(count):
    if ((i>>j)&1):
      sign[j]='+'
  formula=''
  for k in range(count):
    formula += S[k] + sign[k]
  formula += S[count]
  if eval(formula)==7:
    print(formula)
    break

Fixed, accepted submission:
S = input()
count = len(S)-1
for i in range(2**count):
  sign=['-']*count
  for j in range(count):
    if ((i>>j)&1):
      sign[j]='+'
  formula=''
  for k in range(count):
    formula += S[k] + sign[k]
  formula += S[count]
  if eval(formula)==7:
    print(formula+'=7')
    break
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int,input().split())
numberlist=[a,b,c]
numberlist.sort()
if (numberlist[0]==5 and numberlist[1]==5 and numberlist==[2]==7):
    print('YES')
else :
    print('NO')

    

Fixed, accepted submission:
a,b,c = map(int,input().split())
numberlist=[a,b,c]
numberlist.sort()
if (numberlist[0]==5 and numberlist[1]==5 and numberlist[2]==7):
    print('YES')
else :
    print('NO')
Problem:
Given positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.

Incorrect submission (verdict: Wrong Answer):
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
for x in range(b):
 y=(c-a*x)/b
 if int(y)==y:x=x;print(y);break
print(x,y)


Fixed, accepted submission:
r,s=map(int,input().split())
a=d=1;b=c=0
while s:q=r//s;r,s,a,c,b,d=s,r%s,c,a-q*c,d,b-q*d
print(a,b)
Problem:
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows:    * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.   * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.  You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.

Incorrect submission (verdict: Wrong Answer):
n, m = map(int, input().split())
for i in range(m):
    num1 = 1 + i
    num2 = 2 * m - i
    print(num1, num2, sep=" ")


Fixed, accepted submission:
n, m = map(int, input().split())
if m % 2 == 1:

    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2 + 1):
        num1 = m + 1 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
else:
    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2):
        num1 = m + 2 + i
        num2 = 2 * m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
a,b=map(int, input().split()) 
print("error" if a*b>=10 else a*b)

Fixed, accepted submission:
a,b=map(int, input().split()) 
print("error" if a+b>=10 else a+b)
Problem:
There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.  When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness.  Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end".  Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end".

Incorrect submission (verdict: Wrong Answer):
n = int(input())
AB = [list(map(int,input().split())) for _ in range(n)]
AB = sorted(AB,key=lambda x:x[0] - x[1])
print(AB)

t = 0
a = 0
for i in range(n):
    if i % 2 == 0:
        t += AB.pop(0)[0]
    else:
        a += AB.pop(0)[1]
print(t-a)


Fixed, accepted submission:
n = int(input())
AB = [tuple(map(int,input().split())) for _ in range(n)]
all_b = sum([b for _,b in AB])
AB = sorted([a + b for a,b in AB],reverse=True)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB[i]
print(ans - all_b)
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):
s=input()
for i in range(8):
    ans=s[0]
    cnt=int(s[0])
    for j in range(3):
        if i>>j & 1:
            ans+="+"+s[j+1]
            cnt+=int(s[j+1])
        else:
            ans+="-"+s[j+1]
    if cnt==7:
        print(ans+"+=7")

Fixed, accepted submission:
a,*x=list(map(int,input()))
for i in range(8):
    k=a
    ans=str(a)
    for j in range(3):
        if i>>j&1:
            k+=x[j]
            ans+="+"+str(x[j])
        else:
            k-=x[j]
            ans+="-"+str(x[j])
    if k==7:
        print(ans+"=7")
        exit()
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
c = int(input())
print(int((a+b)*c/2))

Fixed, accepted submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
if n <= k:
        ans = x*n
else:
        ans = x*k + y*(n-k)
print(ans)
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while True:
    x = input()
    if '?' in x:
        break
    print(eval(x))

Fixed, accepted submission:
while True:
    x = input()
    if '?' in x:
        break
    print(int(eval(x)))
Problem:
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.  You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing.  The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.

Incorrect submission (verdict: Wrong Answer):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    persons = list(map(lambda x: x, inputs[0]))
    N = len(persons)
    counts = []
    for leader, _ in enumerate(persons):
        count = 0
        for p in range(0, leader):
            if persons[p] == "W":
                count += 1
        for p in range(leader + 1, N):
            if persons[p] == "E":
                count += 1
        counts.append(count)
    min = counts[0]
    for count in counts:
        if min > count:
            min = count

    return min


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Fixed, accepted submission:
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    persons = list(inputs[0])

    count = [persons[1:].count("E")]

    for i in range(1, len(persons)):
        if i == 0:
            continue

        tmp = count[-1]
        if persons[i - 1] == 'W':
            tmp += 1
        if persons[i] == 'E':
            tmp -= 1
        count.append(tmp)

    return min(count)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)