TnT/CodeNet4Repair huggingface dataset:
Problem:
_n_ _q_   _name 1 time1_   _name 2 time2_   ...   _name n timen_    In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space.  In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.

Incorrect submission (verdict: Wrong Answer):
#operand.py using polish way of expressing
data = input()
operators = "+-*/"
command = data.split()

operand = []  #used to store operand"s"
for com in command:
    if com in operators: #do some calculation on the last one and the second last one XD
        second = operand.pop()
        first = operand.pop()

        if com == '+':
            out = first + second
        elif com == "-":
            out = first - second
        elif com == "*":
            out = first * second
        elif com == "/":
            out = first / second
        operand.append(out)
        out = int() #clear out
    else:  #store operand into to buffer
        operand.append(int(com))

print(operand[0])


Fixed, accepted submission:
#getting input
statements = []
while True:
    try:
        line = str(input())
    except EOFError:
        break
    statements.append(line)

pair = statements.pop(0).split()
amount = int(pair[0])
quantum = int(pair[1])

#process input
queue = []
for state in statements:
    pair = state.split()
    name = pair[0]
    time = int(pair[1])
    queue.append([name,time])



done_list = list()
time_spend = 0
while True:
    if not len(queue) > 0:
        break
    task = queue[0]


    if task[1] >= quantum: 
        time_spend += quantum
        task[1] = task[1] - quantum
    else:
        time_spend += task[1]
        task[1] = 0

    if task[1] <= 0: #finished
        task.append(time_spend)   #name,left_time, finished time
        done_list.append((task[0],task[2])) #name and finished time
        queue.remove(task)
    else:
        temp = task
        queue.remove(task)
        queue.append(temp)

for result in done_list:
    print(result[0],end=' ')
    print(result[1])
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

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

from_1 = []
to_n = []

for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        from_1.append(b)
    if b == n:
        to_n.append(a)

if len(set(from_1) - set(to_n)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

from_1 = []
to_n = []

for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
      from_1.append(b)
    if a == n:
      to_n.append(b)
    if b == 1:
      from_1.append(a)
    if b == n:
        to_n.append(a)

if len(set(from_1) & set(to_n)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
Problem:
Your task is to simulate a flood damage.  For a given cross-section diagram, reports areas of flooded sections.         Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.

Incorrect submission (verdict: Wrong Answer):
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                print(p)
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)

Fixed, accepted submission:
g = input()
l = []
q = []
n = 0
for x in range(len(g)):
    if g[x] == '\\':
        if n:
            l.append(n)
            n = 0
            if q:
                q.append(-1)
        q.append(x)
    elif g[x] == '/':
        if q:
            while True:
                p = q.pop()
                if p == -1:
                    n += l.pop()
                else:
                    break
            n += x-p
    else:
        pass
if n:
    l.append(n)
for j in range(l.count(0)):
    l.remove(0)
print(sum(l))
print(len(l), *l)
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 (a-b)>x:
  print('dangerous')
elif (a-b)>0:
  print('safe')
else:
  print('delicious')

Fixed, accepted submission:
x, a, b = map(int, input().split())
if (b-a)>x:
  print('dangerous')
elif (b-a)>0:
  print('safe')
else:
  print('delicious')
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 = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = strl[0]
for t in strl:
  s += str(t)
print(s)

Fixed, accepted submission:
N, L = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = ''
for t in strl:
  s += str(t)
print(s)
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
h,w=map(int,input().split())
print(h*w//2 if h//2==0 or w//2==0 else h*w//2+1)

Fixed, accepted submission:
from math import ceil
h,w=map(int,input().split())
print(1 if h==1 or w==1 else ceil(w*h/2))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

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

Fixed, accepted submission:
N = int(input())
print((1000-N)%1000)
Problem:
今まで登ったことのある山の標高を記録したデータがあります。このデータを読み込んで、一番高い山と一番低い山の標高差を出力するプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):
try:
  while True:
    lst=[]
    a=list(input())
    lst.append(a)
  lst.sort()
  print(max(lst)-min(lst))
except EOFError:
  pass
 
    

Fixed, accepted submission:
try:
  lst=[]
  while True:
   a=float(input())
   lst.append(a)
except :
  print(max(lst)-min(lst))
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 = str(input())
l = list(s)

for i in range(1 << len(s)-1):
    li = ''
    
    for j in range(len(s)):
        li += l[j]
        if j == len(s)-1:
            continue
        if i & (1 << j):
            li += '+'
        else:
            li += '-'
#     print(li)
    r = eval(li)
    if r == 7:
        break
        
print(li)

Fixed, accepted submission:
s = str(input())
l = list(s)

for i in range(1 << len(s)-1):
    li = ''
    
    for j in range(len(s)):
        li += l[j]
        if j == len(s)-1:
            continue
        if i & (1 << j):
            li += '+'
        else:
            li += '-'
#     print(li)
    r = eval(li)
    if r == 7:
        break
        
print(li+'=7')
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 = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
N = len(list(set(n)))
M = len(list(set(m)))
print(abs(N-M))

Fixed, accepted submission:
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))
print(max(0, max(n.count(l[i]) - m.count(l[i]) for i in range(len(l)))))
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):
s=list(input())
string=0
for i in range(0,3):
    if s[i]==1:
        string+=1
print(string)

Fixed, accepted submission:
x = input()
print(x.count('1'))
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
while True:
    (x, y) = [int(i) for i in input().split()]
    if x == 0 and y == 0:
        break
    if x >= y :
        print(x, y)
    else:
         print(x, y)

Fixed, accepted submission:
while True:
    (x, y) = [int(i) for i in input().split()]
    if x == 0 and y == 0:
        break
    if x >= y :
        print(y, x)
    else:
        print(x, y)
Problem:
Write a program which reads an integer and prints sum of its digits.

Incorrect submission (verdict: Wrong Answer):
import sys
from functools import reduce
for line in sys.stdin:
    if line == "0":
        break
    s = reduce(lambda a,b: str(a)+str(b), line.strip())
    print(s)

Fixed, accepted submission:
import sys
from functools import reduce
for line in sys.stdin:
    if int(line) == 0:
        break
    s = reduce(lambda a,b: int(a)+int(b), line.strip())
    print(s)
Problem:
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.  Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = [0]*N

m = 0

ans = 0

count = 0

for i in range(N):
    A[i] =  int(input())
    if(m>A[i]):
        m = A[i]
    elif(m == A[i]):
        count +=1
ans =N-count
print(ans)

Fixed, accepted submission:
N = int(input())
A = [0]*N

m = 0

ans = 0

count = 0

for i in range(N):
    A[i] =  int(input())
A.sort()
for i in range(N):
    if(m<A[i]):
        m =A[i]
    elif(m == A[i]):
        count +=1
ans = N - count
print(ans)
Problem:
A Hitachi string is a concatenation of one or more copies of the string `hi`.  For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not.  Given a string S, determine whether S is a Hitachi string.

Incorrect submission (verdict: Wrong Answer):
s=input()
for i in range(6):
    if s=="hi"*i:
        print("Yes")
print("No")

Fixed, accepted submission:
s=input()
for i in range(6):
    if s=="hi"*i:
        print("Yes")
        exit()
print("No")
Problem:
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Incorrect submission (verdict: Wrong Answer):
import math
a,b,c = map(int,input().split())
x = math.sqrt(a)
y = math.sqrt(b)
z = math.sqrt(c)
if x+y<z:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
from decimal import *
a,b,c = map(int,input().split())
l = Decimal(a)
m = Decimal(b)
n = Decimal(c)
g = Decimal(l*m)
x = a + b + 2*(g.sqrt())
if x<c:
    print("Yes")
else:
    print("No")
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=int(input())
b=int(input())
c=int(input())
x=int(input())

c=0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            y=500*i+100*j+50*k
            print(i,j,k,y)
            if x==y:
                c+=1

print(c)

Fixed, accepted submission:
a=int(input())
b=int(input())
c=int(input())
x=int(input())

count=0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            y=500*i+100*j+50*k
            if x==y:
                count+=1

print(count)
Problem:
You are given three integers A, B and C.  Determine if there exists an equilateral triangle whose sides have lengths A, B and C.

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


Fixed, accepted submission:
a, b, c = map(int, input().split())
if a == b == c:
    print("Yes")
else:
    print("No")
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):
nums = list(map(int,input().split(' ')))
nums.sort()
if nums == [5,5,7]:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
nums = list(map(int,input().split(' ')))
nums.sort()
if nums == [5,5,7]:
  print('YES')
else:
  print('NO')
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())
if (a*b)%2 == 1:
  print("Even")
else:
  print("Odd")

Fixed, accepted submission:
a, b = map(int, input().split())
if (a*b)%2 == 1:
  print("Odd")
else:
  print("Even")
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 = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a):
  s = 500 * a
  for j in range(b):
    t = 100 * b
    for k in range(c):
      u = 50 * c
      if s + t + u == x:
        count += 1

print(count)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a + 1):
  s = 500 * i
  for j in range(b + 1):
    t = 100 * j
    for k in range(c + 1):
      u = 50 * k
      if s + t + u == x:
        count += 1

print(count)
Problem:
A railroad running from west to east in Atcoder Kingdom is now complete.  There are N stations on the railroad, numbered 1 through N from west to east.  Tomorrow, the opening ceremony of the railroad will take place.  On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.  The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.  Here, it is guaranteed that F_i divides S_i.  That is, for each Time t satisfying S_i≤t and t％F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A％B denotes A modulo B, and there will be no other trains.  For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
li =[list(map(int, input().split())) for _ in range(n-1)]
print(li)
for i in range(n):
    t = 0
    for j in range(i,n-1):
        if t <= li[j][1]:
            t =  li[j][1] + li[j][0]
        else:
            k = t  // li[j][2]
            if t % li[j][2] == 0:
                t += li[j][0]
            else:
                t += li[j][0] + (li[j][2] -   t % li[j][2])
    print(t)

Fixed, accepted submission:
n = int(input())
li =[list(map(int, input().split())) for _ in range(n-1)]
for i in range(n):
    t = 0
    for j in range(i,n-1):
        if t <= li[j][1]:
            t =  li[j][1] + li[j][0]
        else:
            k = t  // li[j][2]
            if t % li[j][2] == 0:
                t += li[j][0]
            else:
                t += li[j][0] + (li[j][2] -   t % li[j][2])
    print(t)
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=input()
if s[0]==s[2]:
  print('C')
elif s[0]==s[4]:
  print('B')
else:
  print('A')

Fixed, accepted submission:
a,b,c=map(int,input().split())
if a==b:
  print(c)
elif a==c:
  print(b)
else:
  print(a)
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
S = int(input())
h = 60 / 60
m = 60 % 60
s = 60 % 60
print(h,m,s,sep=':')

Fixed, accepted submission:
S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep=':')
Problem:
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.  The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it.  Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.  Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Incorrect submission (verdict: Time Limit Exceeded):
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)

cnt = 0
prev = 1
while True:
  nxt = A[prev]
  cnt += 1
  
  if nxt == 2:
    break
    
  USED[prev] = True
  if USED[nxt]:
    cnt = -1
    break
    
print(cnt)

Fixed, accepted submission:
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)

cnt = 0
prev = 1
while True:
  nxt = A[prev]
  cnt += 1
  
  if nxt == 2:
    break
    
  USED[prev] = True
  if USED[nxt]:
    cnt = -1
    break
    
  prev = nxt
    
print(cnt)
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

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

hour=int(a/3600)
min=int((a-hour*3600)/60)
sec=a-hour*3600-min*60

print(str(hour)+" "+str(min)+" "+str(sec))


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


print(x//3600,x//60%60,x%60,sep=':')
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 = map(int, input().split())

if n - 1 > k:
    print("Yes")
else:
    print("No")

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

if n % 2 == 1:
    if (n+1)/2 >= k:
        print("YES")
    else:
        print("NO")
else:
    if n/2 >= k:
        print("YES")
    else:
        print("NO")
Problem:
Write a program which solve a simultaneous equation:      ax + by = c   dx + ey = f      The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.

Incorrect submission (verdict: Wrong Answer):
import sys
for line in sys.stdin:
    a,b,c,d,e,f = map(float, line.split())
    print((c*e-b*f)/(a*e-b*d), (a*f-c*d)/(a*e-b*d))

Fixed, accepted submission:
import sys
for line in sys.stdin:
    a,b,c,d,e,f = map(float, line.split())
    x = round((c*e-b*f)/(a*e-b*d), 3)
    y = round((a*f-c*d)/(a*e-b*d), 3)
    if x == -0:
        x = 0
    if y == -0:
        y = 0
    print("{0:.3f}".format(x), "{0:.3f}".format(y))