TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math
x = int(input())

year = 0
y = 100
t = True
while t:
    year += 1
    y = math.floor(y*1.01)
    if y > x:
        print(year)
        t = False


Fixed, accepted submission:
import math
x = int(input())

year = 0
y = 100
t = True
while t:
    year += 1
    y = math.floor(y*1.01)
    if y >= x:
        print(year)
        t = False
Problem:
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**.  Here, an sequence b is a **good sequence** when the following condition holds true:    * For each element x in b, the value x occurs exactly x times in b.  For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.  Find the minimum number of elements that needs to be removed so that a will be a good sequence.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
ans=0
for i in range(n):
  if arr[i]<=10**5:
    cnt[arr[i]]+=1
  else:
    ans+=1
for i in range(1,10**5+1):
  if cnt[i]>i:
    ans+=cnt[i]-i
  else:
    ans+=i-cnt[i]
print(ans)

Fixed, accepted submission:
n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
ans=0
for i in range(n):
  if arr[i]<=10**5:
    cnt[arr[i]]+=1
  else:
    ans+=1
for i in range(1,10**5+1):
  if cnt[i]==0:
    continue
  elif cnt[i]==i:
    continue
  elif cnt[i]>i:
    ans+=cnt[i]-i
  else:
    ans+=cnt[i]
print(ans)
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(1000 - (N % 1000))
else:
    print(0)
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

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

if (a[0] == b[2]) and (a[1] == b[1]) and (a[2] == b[0]):
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
a = input()
b = input()

if (a[0] == b[2]) and (a[1] == b[1]) and (a[2] == b[0]):
    print('YES')
else:
    print('NO')
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
s=list(map(int,input().split()))
print(sum(s)-min(s)-max(s))

Fixed, accepted submission:
s=list(map(int,input().split()))
print(2*min(s)+2*max(s)-sum(s))
Problem:
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.  Assume that initially no person lives in the building.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]=v
for i in range(4):
    for j in range(3):
        for e in range(10):
            print(' '+str(a[i][j][e]),end='')
        print()
    print('#'*20)


Fixed, accepted submission:
n=int(input())
a=[[[0]*10 for i in range(3)] for j in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for e in range(10):
            print(' '+str(a[i][j][e]),end='')
        print()
    if i!=3:
        print('#'*20)
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
a, b, x = map(int, input().split(" "))
print(int(b + 1 - a) // x)

Fixed, accepted submission:
a, b, x = map(int, input().split(" "))
if a % x == 0:
  print(int(b//x) - int(a//x) + 1)
else:
  print(int(b//x) - int(a//x))
Problem:
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.

Incorrect submission (verdict: Wrong Answer):
d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
    s_i=list(map(int,input().split()))
    s.append(s_i)
for _ in range(d):
    t=int(input())

dp=[0]*26

for i in range(d):
    s_i = max(s[i])
    index=s[i].index(max(s[i]))
    dp[index]=i+1

    tmp=0

    for j in range(26):
        tmp+=c[j]*(d-dp[j])

    ans = s_i = tmp
    print(ans)

Fixed, accepted submission:
d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
    s_i=list(map(int,input().split()))
    s.append(s_i)
t=[]
for _ in range(d):
    t_i=int(input())
    t.append(t_i)


dp=[0]*26

ans=0
for i in range(d):
    s_i = s[i][t[i]-1]
    ans+=s_i
    dp[t[i]-1]=i+1
    tmp=0
    for j in range(26):
        tmp+=c[j]*((i+1)-dp[j])

    
    

    ans -= tmp

    print(ans)
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):
s = input()
res =[]
for i in range(len(s)):
	print(res)
	if s[i] == 'B':
		if len(res) != 0:
			res.pop(len(res)-1)
		continue
	res.append(s[i])

print("".join(res))

Fixed, accepted submission:
s = input()
res =[]
for i in range(len(s)):
	if s[i] == 'B':
		if len(res) != 0:
			res.pop(len(res)-1)
		continue
	res.append(s[i])

print("".join(res))
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
print("No")

Fixed, accepted submission:
from collections import deque

print("Yes")

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

q = deque([0])
b = [0] * n
while q:
    x = q.popleft()
    for i in g[x]:
        if b[i] != 0:
            continue
        b[i] = x + 1
        q.append(i)

print(*b[1:], sep="\n")
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
A,B,X = map(int,input().split())
print("YES" if A+B == X or A == X else "NO")

Fixed, accepted submission:
A,B,X = map(int,input().split())
print("YES" if A <= X <= A+B else "NO")
Problem:
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
  m[i]-=m[i-1]
ans=99999999
for i in m:
  ans=min(ans,abs(a-i-i))
print(ans)

Fixed, accepted submission:
n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
  m[i]+=m[i-1]
ans=99999999999999
for i in m[:n-1]:
  ans=min(ans,abs(a-i-i))
print(ans)
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a_list = list(map(int, input().split()))

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    index = a_count - rev_index - 1
    if (a + 1) * 2 > a_count:
        boll_list[index] = a_list[index]
    else:
        divide_max = a_count // (index + 1)
        total = 0
        for i in range(divide_max):
            total += boll_list[i]
        total = total % 2
        if a_list[index] != total:
            boll_list[index] = 1

if (1 in boll_list):
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(' '.join(output_list))
else:
    print('0')

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

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    
    index = a_count - rev_index - 1
    divide_max = a_count // (index + 1)
    total = 0
    for divide in range(divide_max):
        total += boll_list[(index + 1) * (divide + 1) - 1]
    if a_list[index] != total % 2:
        boll_list[index] = 1

if 1 in boll_list:
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(len(output_list))
    print(' '.join(output_list))
else:
    print('0')
Problem:
Write a program which identifies the number of combinations of three integers which satisfy the following conditions:    * You should select three distinct integers from 1 to n.   * A total sum of the three integers is x.  For example, there are two combinations for n = 5 and x = 9.    * 1 + 3 + 5 = 9   * 2 + 3 + 4 = 9

Incorrect submission (verdict: Wrong Answer):
#coding:utf-8
#1_7_B 2015.4.5
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break
    count = 0
    
    for i in range(1 , n + 1):
        for j in range(1 , n + 1):
            if (x - i - j) < n and i < j < (x - i -j):
                count += 1
    print(count)

Fixed, accepted submission:
#coding:utf-8
#1_7_B 2015.4.5
while True:
    n,x = map(int,input().split())
    if n == x == 0:
        break
    count = 0
    
    for i in range(1 , n + 1):
        for j in range(1 , n + 1):
            if i < j < (x - i - j) <= n:
                count += 1
    print(count)
Problem:
We held two competitions: Coding Contest and Robot Maneuver.  In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.  DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.

Incorrect submission (verdict: Wrong Answer):
x,y = map(int,input().split())
c = 0
if x==1:
    c+=300000
elif x == 2:
    c+=200000
elif x == 3:
    c+=100000
    
if y==1:
    c+=300000
elif y == 2:
    c+=200000
elif y == 3:
    c+=100000

if x == 1 and y == 1:
    x+=400000
print(c)

Fixed, accepted submission:
x,y = map(int,input().split())
c = 0
if x==1:
    c+=300000
elif x == 2:
    c+=200000
elif x == 3:
    c+=100000
    
if y==1:
    c+=300000
elif y == 2:
    c+=200000
elif y == 3:
    c+=100000

if x == 1 and y == 1:
    c+=400000
    
print(c)
Problem:
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).  We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:    * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1.  Find the minimum total cost required to collect all the balls when we optimally choose p and q.

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

a = [list(map(int,input().split())) for _ in range(n)]

lst = []

for i in range(n):
    for j in range(i,n):
        if a[j][0]-a[i][0] <= 0 and a[j][1]-a[i][1] <= 0:
            lst.append([a[i][0]-a[j][0], a[i][1]-a[j][1]])
        else:
            lst.append([a[j][0]-a[i][0], a[j][1]-a[i][1]])

if n ==1:
    print(1)
else:
    x = 0
    for i in range(len(a)):
        c = 0
        for j in range(i,len(a)):
            if a[i] == a[j]:
                c += 1
        x = max(x,c)
    print(n-x-1)

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

a = [list(map(int,input().split())) for _ in range(n)]

lst = []

for i in range(n):
    for j in range(i+1,n):
        if a[j][0]-a[i][0] < 0:
            lst.append([a[i][0]-a[j][0], a[i][1]-a[j][1]])
        if a[j][0]-a[i][0] == 0:
            lst.append([a[i][0]-a[j][0], abs(a[i][1]-a[j][1])])
        else:
            lst.append([a[j][0]-a[i][0], a[j][1]-a[i][1]])

if n ==1:
    print(1)
else:
    x = 0
    for i in range(len(lst)):
        c = 1
        for j in range(i+1,len(lst)):
            if lst[i] == lst[j]:
                c += 1
        x = max(x,c)
    print(n-x)
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())
print((1 + n) * n / 2)

Fixed, accepted submission:
n = int(input())
print((1 + n) * n // 2)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):

A, B, K = map(int, input().split())

if A+K-1 >= B-K+1:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K-1):
        print(i)
    for i in range(B-K+1, B):
        print(i)

Fixed, accepted submission:
A, B, K = map(int, input().split())

if A+K-1 >= B-K+1:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1, B+1):
        print(i)
Problem:
Snuke loves working out. He is now exercising N times.  Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i.  Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
p = 1
for i in range(1, n+1):
    p *= i
print(p % 10**9 + 7)

Fixed, accepted submission:
n = int(input())
p, d =1, 10**9+7
for i in range(1,n+1):
  p = (p*i) % d
print(p)
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
A = sorted(list(map(int,input().split())))
N = int(input())
A[-1] = A[-1]**N
print(sum(A))

Fixed, accepted submission:
A = sorted(list(map(int,input().split())))
N = int(input())
A[-1] = A[-1]*2**N
print(sum(A))
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):
while(1):
	chuukan, kimatsu, saishi = map(int, input().split())
	state = "None"
	
	if chuukan == kimatsu == saishi == -1:
		break
	elif (chuukan or kimatsu) == -1:
		state = "F"
	elif (chuukan*2 + kimatsu*2)/2 >= 80:
		state = "A"
	elif (chuukan*2 + kimatsu*2)/2 >= 65:
		state = "B"
	elif (chuukan*2 + kimatsu*2)/2 >= 50:
		state = "C"
	elif (chuukan*2 + kimatsu*2)/2 >= 30:
		if saishi >= 50:
			state = "C"
		else:
			state = "B"
	else:
		state = "D"

	print("DBG ::chuukan{} kimatsu{} saishi{} STATE[{}]".format(chuukan, kimatsu, saishi, state))

Fixed, accepted submission:
mid = 0
end = 0
re = 0

while(1):
    mid, end, re = map(int, input().split() )
    if (mid == -1) and (end == -1) and (re == -1) :
        break

    if (mid == -1) or (end == -1):
        print("F")
    elif mid + end >= 80:
        print("A")
    elif mid + end >= 65:
        print("B")
    elif mid + end >= 50:
        print("C")
    elif mid + end >= 30:
        if re >= 50:
            print("C")
        else: print("D")
    else: print("F")
Problem:
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered.  This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source.  DFS timestamps each vertex as follows:    * $d[v]$ records when $v$ is first discovered.   * $f[v]$ records when the search finishes examining $v$’s adjacency list.  Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules:    * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively.   * IDs in the adjacency list are arranged in ascending order.   * The program should report the discover time and the finish time for each vertex.   * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID.   * The timestamp starts with 1.

Incorrect submission (verdict: Wrong Answer):

d = None
f = None


def dfs(g, cur, time):
    global d, f
    d[cur] = time
    for next in g[cur]:
        if d[next] == 0:
            time = dfs(g, next, time+1)
    f[cur] = time + 1
    return time + 1


def main():
    global d, f
    n = int(input())
    g = [[] for _ in range(n)]
    d = [0 for _ in range(n)]
    f = [0 for _ in range(n)]
    for _ in range(n):
        inp = list(map(int, input().split()))
        m = inp[0] - 1
        k = inp[1]
        for i in range(k):
            g[m].append(inp[i+2] - 1)
    dfs(g, 0, 1)
    for i in range(n):
        print(i, d[i], f[i])


if __name__ == '__main__':
    main()



Fixed, accepted submission:

d = None
f = None


def dfs(g, cur, time):
    global d, f
    d[cur] = time
    for next in g[cur]:
        if d[next] == 0:
            time = dfs(g, next, time+1)
    f[cur] = time + 1
    return time + 1


def main():
    global d, f
    n = int(input())
    g = [[] for _ in range(n)]
    d = [0 for _ in range(n)]
    f = [0 for _ in range(n)]
    for _ in range(n):
        inp = list(map(int, input().split()))
        m = inp[0] - 1
        k = inp[1]
        for i in range(k):
            g[m].append(inp[i+2] - 1)
    time = 1
    for i in range(n):
        if d[i] == 0:
            time = dfs(g, i, time) + 1
    for i in range(n):
        print(i+1, d[i], f[i])


if __name__ == '__main__':
    main()