TnT/CodeNet4Repair huggingface dataset:
Problem:
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.  How many grams of sand will the upper bulb contains after t seconds?

Incorrect submission (verdict: Wrong Answer):
X,t = map(int,input().split())
if t >= X:
  print(0)
else:
  print(t - X)

Fixed, accepted submission:
X,t = map(int,input().split())
if t >= X:
  print(0)
else:
  print(X - t)
Problem:
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i.  Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0.  Now, the following Q operations will be performed:    * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j.  Find the value of the counter on each vertex after all operations.

Incorrect submission (verdict: Wrong Answer):
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

N, Q = map(int, input().split())

graph   = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }

for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())

    graph[a].append(b)

for _ in range(Q):
    p, q = map(int, input().split())

    queries[p - 1] += q

def dfs(p, acc):
    acc += queries[p]

    print(acc)

    for child in graph[p]:
        dfs(child, acc)

dfs(0, 0)

Fixed, accepted submission:
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

N, Q = map(int, input().split())

graph   = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }

for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())

    graph[a].append(b)
    graph[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())

    queries[p - 1] += x

answer = [ 0 ] * N

def dfs(p, p_before, acc):
    acc += queries[p]

    answer[p] = acc

    for child in graph[p]:
        if child == p_before:
            continue

        dfs(child, p, acc)

dfs(0, -1, 0)

print(*answer)
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):
def main():
    X = int(input())
    yen = 100
    ans = 0
    while yen >= X:
        yen = int(yen ** (1.01))
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Fixed, accepted submission:
def main():
    X = int(input())
    yen = 100
    ans = 0
    while yen < X:
        yen = int(1.01*yen)
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):

r, g, b = map(int,input().split())

X = 100 * r + g * 10 + b

if X % 4 == 0:
    print('Yes')

else:
     print('NO')

Fixed, accepted submission:

r, g, b = map(int,input().split())

X = 100 * r + g * 10 + b

if X % 4 == 0:
    print('YES')

else:
     print('NO')
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
N, L = map(int, input().split())
SList = []
for i in range(N):
    SList.append(input())
SList.sort()
print(','.join(SList))


Fixed, accepted submission:
N, L = map(int, input().split())
SList = []
for i in range(N):
    SList.append(input())
SList.sort()
ans = "".join(SList)
print(ans)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a,b = map(int,input().split())
print("Even" if a*b/2==0 else "Odd")

Fixed, accepted submission:
a,b=map(int,input().split())
print("Even" if a*b%2==0 else "Odd")
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()
l = S.__len__()
for i in range((l-1)//2,0,-1):
  if S[0:i-1] == S[i:i+i-1]:
    print(2*i)


Fixed, accepted submission:
S = input()
l = S.__len__()
for i in range((l-1)//2,0,-1):
  if S[0:i-1] == S[i:i+i-1]:
    print(2*i)
    break
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

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

for x in range(0,len(s),2):
  print(s[x])
  

Fixed, accepted submission:
s = input()
print(s[::2])
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):
abc = list(map(int,input().split()))
abc.sort()

if abc[2]-(abc[1]+abc[0]) == 0:
    print('YES')
else:
    print('NO')

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

if abc[2]-(abc[1]+abc[0]) == 0:
    print('Yes')
else:
    print('No')
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):
blue_list = []
red_list = []
cnt = 0

N = int(input())
for _ in range(N):
  blue_list.append(input())
M = int(input())
for _ in range(M):
  red_list.append(input())
  
for word in blue_list:
  if word in red_list:
    pass
  else:
    cnt+=1
    
print(cnt)

Fixed, accepted submission:
blue_list = []
red_list = []
diff_list = []

N = int(input())
for _ in range(N):
  blue_list.append(input())
M = int(input())
for _ in range(M):
  red_list.append(input())
  
for word in set(blue_list):
    diff_list.append(blue_list.count(word)-red_list.count(word))
    
print(max(0,max(diff_list)))
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
n,a,b=map(int,input().split())
s=input()
nat=0
intnat=0
for i in range(n):
  if s[i]=="a":
    if nat<a+b:
      print("Yes")
      nat+=1
    else:
      print("No")
  elif i=="b":
    if nat<a+b and intnat<b:
      print("Yes")
      nat+=1
      intnat+=1
    else:
      print("No")
  else:
    print("No")

Fixed, accepted submission:
n,a,b=map(int,input().split())
s=input()
kakutei=0
kaigai=0
for i in range(n):
  if s[i]=="a":
    if kakutei < a+b:
      print("Yes")
      kakutei += 1
    else:
      print("No")
  elif s[i]=="b":
    if kakutei < a+b and kaigai < b:
      print("Yes")
      kakutei += 1
      kaigai += 1
    else:
      print("No")
  else:
    print("No")
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
n,k=(int(x) for x in input().split())

if n%2==0:
  if k<=n//2:
    print("Yes")
  else:
    print("No")

if n%2==1:
  if k<=n//2+1:
    print("Yes")
  else:
    print("No")
    

Fixed, accepted submission:
n,k=(int(x) for x in input().split())

if n%2==0:
  if k<=n//2:
    print("YES")
  else:
    print("NO")

else:
  if k<=n//2+1:
    print("YES")
  else:
    print("NO")
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):
print("Yes" if input() in "9" else "No")

Fixed, accepted submission:
print("Yes" if "9" in input() else "No")
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())
s=N*(N+1)/2
print(s)

Fixed, accepted submission:
N=int(input())
s=N*(N+1)/2
print(int(s))
Problem:
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.

Incorrect submission (verdict: Wrong Answer):
s = input()
print('yneos'[len(s)>len(set(s))])

Fixed, accepted submission:
s = input()
print('yneos'[len(s)>len(set(s))::2])
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(str, input().split())

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int, input().split())

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")
Problem:
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
    if n != 1:
      a.append(n)
  return a

n=int(input())

x=[0]*1000
for i in range(2,n+1):
  for _ in prime_factorize(i):
    x[_]+=1

ans=1
for _ in x:
  if _ > 0:
    ans=(ans*(_+1))%(10**9+7)

print(ans)
    
x.sort()







Fixed, accepted submission:
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
      a.append(n)
  return a

n=int(input())

x=[0]*1000
for i in range(2,n+1):
  p=prime_factorize(i)
  for _ in p:
    x[_]+=1

ans=1
for _ in x:
  if _ > 0:
    ans=(ans*(_+1))%(10**9+7)

print(ans)
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
import sys

s = input()
c = 0

for i in range(len(s)):
    if s[i] == 'A':
        while(s[i] != 'Z'):
            c += 1
            i += 1
        if s[i] == 'Z':
            c += 1
            exit()
            
print(c)

Fixed, accepted submission:
import sys

s = input()
c = 0
C = 0

for i in range(len(s)):
    if s[i] == 'A':
        break

for j in range(len(s)):
    if s[-j] == 'Z':
        break
print(len(s[i:len(s) - j + 1]))
Problem:
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).   Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`.   However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.   Determine if square1001 can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
import sys

def is_black_in_four_dir(char_list, pos):
    for p in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        if square_list[pos[1]+p[1]][pos[0]+p[0]] == "#":
            return True
    return False

h, w = map(lambda x: int(x), input().split(" "))
square_list = [input() for i in range(h)]

square_list = ["."*(w+2)] + ["." + s + "." for s in square_list] + ["."*(w+2)]

print(square_list)

for y in range(1, h+2):
    for x in range(1, w+2):
        if square_list[y][x] == "#":
            if not is_black_in_four_dir(square_list, (x, y)):
                print("No")
                sys.exit()
    
print("Yes")

Fixed, accepted submission:
import sys

def get_value_by_lists(values_list, pos):
    h, w = len(values_list), len(values_list[0])
    if 0 <= pos[1] < h and 0 <= pos[0] < w:
        return values_list[pos[1]][pos[0]]
    else:
        return None

def is_black_in_four_dir(cells_list, pos):
    for p in ((0, 1), (0, -1), (1, 0), (-1, 0)):
        if get_value_by_lists(cells_list, (pos[0]+p[0], pos[1]+p[1])) == "#":
            return True
    return False

h, w = map(lambda x: int(x), input().split(" "))
cells_list = [input() for _ in range(h)]

for y, cells in enumerate(cells_list):
    for x, cell in enumerate(cells):
        if cell == "#" and not (is_black_in_four_dir(cells_list, (x, y))):
            print("No")
            sys.exit()
print("Yes")
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=(int(x) for x in input().split())
b = 0
if x == 1:
    b += 300000
elif x == 2:
    b += 200000
elif x == 3:
    b += 100000
if y == 1:
    b += 300000
elif y == 2:
    b += 200000
elif y == 3:
    b += 100000
elif x == 1 and y == 1:
    b += 400000
else:
    pass
print(b)

Fixed, accepted submission:
x,y=(int(x) for x in input().split())
b = 0
if x == 1:
    b += 300000
elif x == 2:
    b += 200000
elif x == 3:
    b += 100000
else:
    b += 0
if y == 1:
    b += 300000
elif y == 2:
    b += 200000
elif y == 3:
    b += 100000
else:
    b += 0
if x == 1 and y == 1:
    b += 400000

print(b)
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):
num50 = int(input())
num100 = int(input())
num500 = int(input())
amount = int(input())
rst = 0
for itr50 in range(num50):
    for itr100 in range(num100):
        for itr500 in range(num500):
            kingaku = itr50*50+itr100*100+itr500*500
            if(kingaku==amount):
                rst += 1
print(rst)

Fixed, accepted submission:
num500 = int(input())
num100 = int(input())
num50 = int(input())
amount = int(input())
rst = 0
for itr500 in range(num500+1):
    for itr100 in range(num100+1):
        for itr50 in range(num50+1):
            kingaku = itr50*50+itr100*100+itr500*500
            
            
            if(kingaku==amount):
                rst += 1
print(rst)
Problem:
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.   The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.  An edge whose removal disconnects the graph is called a _bridge_.   Find the number of the edges that are bridges among the M edges.

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

dist = { i:[] for i in range(1,N+1)}

for i in range(M):
  a,b = map(int,input().split())
  dist[a].append(b)
  dist[b].append(a)
  
cnt = 0  
for i in range(1,N+1):
  if len(dist[i]) == 1:
    cnt += 1
print(int(cnt))

Fixed, accepted submission:
import numpy as np
from scipy.sparse.csgraph import connected_components
from collections import deque
n,m=map(int,input().split())
matrix=[[0]*n]*n
matrix=np.array(matrix)
l=deque()
for _ in range(m):
    a,b=map(int,input().split())
    l.append([a,b])
    matrix[a-1][b-1]=1
count=0
for i in range(m):
    [a,b]=l.popleft()
    matrix[a-1][b-1]=0
    k,kk=connected_components(matrix)
    if kk[a-1]!=kk[b-1]:
        count+=1
    l.append([a,b])
    matrix[a-1][b-1]=1
print(count)
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 = input().split()
b = sorted(a)
print(b)
if int(b[2]) == int(b[0]) + int(b[1]):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a = map(int,input().split())
b = sorted(a)
if b[0] != 0 and b[1] != 0 and b[2] != 0:
    if b[2] == b[0] + b[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
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):
n = int(input())
s = 100
while n > s:
  s*=1.01
print(int(s))

Fixed, accepted submission:
n = int(input())
s = 100
a = 0
while n > s:
  s= int(s+s//100)
  a += 1
print(a)
Problem:
Snuke built an online judge to hold a programming contest.  When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)  Determine whether the judge can return the string `AC` as the verdict to a program.

Incorrect submission (verdict: Wrong Answer):
s = input()
out = "NO"
for i in range(len(s)):
    if i+1 != len(s):
        if s[i] == "A" and s[i+1] == "C":
            out = "YES"
print(out)
        

Fixed, accepted submission:
s = input()
out = "No"
for i in range(len(s)):
    if i+1 != len(s):
        if s[i] == "A" and s[i+1] == "C":
            out = "Yes"
print(out)
Problem:
There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i. We will play the following single-player game using this graph and a piece.  Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move the piece as follows:    * When the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.  The player can end the game only when the piece is placed at vertex N. The given graph guarantees that it is possible to traverse from vertex 1 to vertex N.  When the player acts optimally to maximize the score at the end of the game, what will the score be? If it is possible to increase the score indefinitely, print `inf`.

Incorrect submission (verdict: Wrong Answer):
def BellmanFord(edges,num_v,source):
    inf=float("inf")
    dist=[inf for i in range(num_v)]
    dist[source-1]=0

    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                if i==num_v-1: return [0,'inf']
    return dist
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BellmanFord(a, n, 1)[-1])

Fixed, accepted submission:
def BF(p,n,s):
    inf=float("inf")
    d=[inf for i in range(n)]
    d[s-1]=0
    for i in range(n+1):
        for e in p:
            if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
        if i==n-1:t=d[-1]
        if i==n and t!=d[-1]:
            return [0,'inf']
    return list(map(lambda x:-x, d))
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BF(a, n, 1)[-1])