TnT/CodeNet4Repair huggingface dataset:
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())

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:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
number = 0
x = input()
x = int(x)
if 1 <= x and x <= 10000:
    number += 1
    print("Case" + str(number) + ":" + str(x))



Fixed, accepted submission:
number = 0
while True:
    x = input()
    x = int(x)
    if x == 0:
        break
    else:
        if 1 <= x and x <= 10000:
            number += 1
            print("Case " + str(number) + ": " + str(x))
Problem:
Niwango-kun is an employee of Dwango Co., Ltd.   One day, he is asked to generate a thumbnail from a video a user submitted.   To generate a thumbnail, he needs to select a frame of the video according to the following procedure:    * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.   * Select t-th frame whose representation a_t is nearest to the average of all frame representations.   * If there are multiple such frames, select the frame with the smallest index.  Find the index t of the frame he should select to generate a thumbnail.

Incorrect submission (verdict: Wrong Answer):
P = int(input())
N = list(map(int,input().split()))
N.reverse()
#print(N)
s = sum(N)/P
minfr=9999
ans = 0
print(s)
for i ,n in enumerate(N):
    minfr = min(minfr,abs(n-s))
    print(minfr,i,n)
    if minfr == abs(n-s):
        ans = i
    # TODO: write code...
print(abs(ans-(P-1)))

Fixed, accepted submission:
P = int(input())
N = list(map(int,input().split()))
N.reverse()
#print(N)
s = sum(N)/P
minfr=9999
ans = 0
#print(s)
for i ,n in enumerate(N):
    minfr = min(minfr,abs(n-s))
    #print(minfr,i,n)
    if minfr == abs(n-s):
        ans = i
    # TODO: write code...
print(abs(ans-(P-1)))
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

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

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
print(int(((a+b)*h)/2))
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
x=int(input())
m=0
if x==1:
    print(1)
else:  
    for i in range(2,50):
        j=2
        while i**j<=x:
            j+=1
        if m<i**(j-1):
            m=i**(j-1)
print(m)

Fixed, accepted submission:
x=int(input())
m=0
if x==1:
    print(1)
else:  
    for i in range(2,50):
        j=2
        while i**j<=x:
            if m<i**j:
                m=i**j
            j+=1
    print(m)
Problem:
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.  He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.  To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.  How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

Incorrect submission (verdict: Wrong Answer):
import bisect
def inpl(): return list(map(int, input().split()))
N = int(input())
a, b, c = sorted(inpl()), sorted(inpl()), sorted(inpl())
print(a)
print(b)
print(c)
ans = 0
for j in b:
    ans += bisect.bisect_left(a, j)*(N-bisect.bisect_right(c, j))
print(ans)

Fixed, accepted submission:
import bisect
def inpl(): return list(map(int, input().split()))
N = int(input())
a, b, c = sorted(inpl()), sorted(inpl()), sorted(inpl())

ans = 0
for j in b:
    ans += bisect.bisect_left(a, j)*(N-bisect.bisect_right(c, j))
print(ans)
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):
while 1:
    try:a,b,c,d,e,f=map(int,input().split())
    except:break
    x=(c*d-a*f)/(b*d-a*e)
    print("%f %f"%((c-b*x)/a,x))

Fixed, accepted submission:
while 1:
    try:a,b,c,d,e,f=map(int,input().split())
    except:break
    x=(c*d-a*f)/(b*d-a*e)
    print("%.3f %.3f"%((c-b*x)/a,x))
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>2*K:
  print("YES")
else:
  print("NO")

Fixed, accepted submission:
N,K=map(int,input().split())
if N>2*K-2:
  print("YES")
else:
  print("NO")
Problem:
販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。

Incorrect submission (verdict: Time Limit Exceeded):
total=0
s=0
i=0
while True:
 try:
  a,b = map(int,input().split(','))
  total += a*b
  s+=b
  i+=1
 except:
   result=s/i
   print(total)
   print(result)

Fixed, accepted submission:
try:
  total=s=i=0 
  while True:
   a,b = map(int,input().split(','))
   total += a*b
   s += b
   i += 1
except:
 print(total)
 print(round(s/i+0.5))
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s = input().replace("eraser", "").replace("erace", "").replace("dreamer", "").replace("dream", "")
if s:
    print("NO")
else:
    print("YES")

Fixed, accepted submission:
s = input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")
if len(s) > 0:
    print("NO")
else:
    print("YES")
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 = list(input())
line = a + b
rank = 0
bnum = 0
for student in s:
    if student == "a" or student== "b":
        if rank <= line:
            rank += 1
            if student == "a":
                print("Yes")
            else:
                bnum += 1
                if bnum <= b:
                    print("Yes")
                else:
                    print("No")
        else:
            print("No")
    else:
        # rank +=1
        print("No")

Fixed, accepted submission:
n, a, b = map(int, input().split())
s = list(input())
line = a + b
rank = 1
bnum = 0
for student in s:
    if student == "a" or student== "b":
        if rank <= line:

            if student == "a":
                print("Yes")
                rank += 1
            else:
                bnum += 1
                if bnum <= b:
                    print("Yes")
                    rank += 1
                else:
                    print("No")
        else:
            print("No")
    else:
        # rank +=1
        print("No")
Problem:
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.  Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan.  Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.

Incorrect submission (verdict: Wrong Answer):
A, B, C, D = map(int,input().split())
if A + B < C + D:
  print("Left")
elif A + B == C + D:
  print("Balanced")
else:
  print("Right")

Fixed, accepted submission:
A, B, C, D = map(int,input().split())
if A + B < C + D:
  print("Right")
elif A + B == C + D:
  print("Balanced")
else:
  print("Left")
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):
#import sys
#input = sys.stdin.readline
def main():
    A = list(input().split())
    five = 0
    seven = 0
    for a in A:
        if len(a) == 5:
            five += 1
        elif len(a)  == 7:
            seven += 1
    if five == 2 and seven == 1:
        print("YES")
    else:
        print("NO")
if __name__ == '__main__':
    main()

Fixed, accepted submission:
#import sys
#input = sys.stdin.readline
def main():
    A = list( map( int, input().split()))
    C = [0]*11
    for a in A:
        C[a] += 1
    if C[5] == 2 and C[7] == 1:
        print("YES")
    else:
        print("NO")
if __name__ == '__main__':
    main()
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):
x, y = map(int, input().split())
setA = []
setA.append({1, 3, 5, 7, 8, 10, 12})
setA.append({4, 6, 9, 11})
setA.append({2})

for s in setA:
  if x in setA and y in setA:
    print("Yes")
    exit()
print("No")

Fixed, accepted submission:
x, y = map(int, input().split())
setA = []
setA.append({1, 3, 5, 7, 8, 10, 12})
setA.append({4, 6, 9, 11})
setA.append({2})
 
for s in setA:
  if x in s and y in s:
    print("Yes")
    exit()
print("No")
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
s = input()
for i in range(1, len(s)):
    if((len(s)-i) % 2 == 0):
        ans = len(s) - i
        print(s[0:ans//2], s[ans//2:ans])
        if(s[0:ans//2] == s[ans//2:ans]):
            print(ans)
            break


Fixed, accepted submission:
s = input()
for i in range(1, len(s)):
    if((len(s)-i) % 2 == 0):
        ans = len(s) - i
        if(s[0:ans//2] == s[ans//2:ans]):
            print(ans)
            break
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

Incorrect submission (verdict: Wrong Answer):
i = list(map(int, input().split()))
a = i[0]
b = i[1]

float_a = float(a)
float_b = float(b)

print(int(a / b), int(a % b), float(a / b))

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

a = i[0]
b = i[1]

print('{0} {1} {2:.5f}'.format(a // b, a % b, float(a / b)))
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
day = input()
if day[3]=='7':
    day = day.replace(day[3], '8')
print(day)

Fixed, accepted submission:
tmp_date = list(input())

if tmp_date[3] == '7':
    tmp_date[3] = '8'
date = ''.join(tmp_date)
print(date)
Problem:
In this problem, we use the 24-hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?

Incorrect submission (verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    h1, m1, h2, m2, k = MI()

    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2

    ans = 0
    for i in range(min1, min2-k, k):
        # print(i)
        ans += k
    print(min(0, ans))


if __name__ == '__main__':
    solve()


Fixed, accepted submission:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    h1, m1, h2, m2, k = MI()

    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2

    # print(min2 - min1)
    print(max(0, min2-min1-k))


if __name__ == '__main__':
    solve()
Problem:
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.  For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares.  Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.  Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int, input().split())

bignum = pow(10,9) + 7

mee = [[0 for i in range(w+1)] for j in range(h)]
#starting should all be 1
#walled = -1

for j in range(h):
    mee[j][0] = 0


for i in range(h):
    temp = input()
    for j in range(w):
        if temp[j] == "#":
            mee[i][j+1] = -1

for i in range(w+1):
    if mee[0][i] == -1:
        break
    mee[0][i] = 1

for i in range(h):
    print(mee[i])


#from top and from left >0 --> +1
#
for i in range(1,h):
    for j in range(1,w+1):
        if mee[i][j] == -1:
            continue
        if mee[i - 1][j] > 0 and mee[i][j - 1] > 0:
            mee[i][j] = mee[i - 1][j] % bignum + mee[i][j - 1] %bignum

        elif mee[i - 1][j] > 0 or mee[i][j - 1] >0:
            mee[i][j] = max(mee[i-1][j],mee[i][j-1])

for i in range(h):
    print(mee[i])
print(mee[-1][-1] % bignum)

Fixed, accepted submission:
h,w = map(int, input().split())

bignum = pow(10,9) + 7

mee = [[0 for i in range(w+1)] for j in range(h)]
#starting should all be 1
#walled = -1

for j in range(h):
    mee[j][0] = 0


for i in range(h):
    temp = input()
    for j in range(w):
        if temp[j] == "#":
            mee[i][j+1] = -1

for i in range(w+1):
    if mee[0][i] == -1:
        break
    mee[0][i] = 1

#from top and from left >0 --> +1
#
for i in range(1,h):
    for j in range(1,w+1):
        if mee[i][j] == -1:
            continue
        if mee[i - 1][j] > 0 and mee[i][j - 1] > 0:
            mee[i][j] = mee[i - 1][j] % bignum + mee[i][j - 1] %bignum

        elif mee[i - 1][j] > 0 or mee[i][j - 1] >0:
            mee[i][j] = max(mee[i-1][j],mee[i][j-1])

print(mee[-1][-1] % bignum)
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
n = int(input()) 
a = int(input()) 
b = n // 500 

if n - (500 * b) - a == 0:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
n = int(input())
a = int(input())
 
if n % 500 <= a:
    print('Yes')
else:
    print('No')
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):
import math
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil((h + w )/2))

Fixed, accepted submission:
import math
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
    print(math.ceil((h * w )/2))
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())
A = list(map(int, input().split()))
print(A)

X = sum(A)
tmps = []
x = 0
for i in range(N-1):
    x += A[i]
    tmps.append(X - 2 * x)
print(tmps)
print(min(tmps,key=lambda x:abs(x)))


Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
tmp = 0
ans = 10 ** 10
Asum = sum(A)
for i in range(N - 1):
    tmp += A[i]
    a = abs((Asum - tmp) - tmp)
    if ans > a:
        ans = a
print(ans)
Problem:
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.  Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.  You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.

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

alp = "ABDEGHIJKLMNOPQRSTUVWXYZ"
for a in alp:
    S = S.replace(a, '')
if 'CF' in S:
    print('YES')
else:
    print('NO')



Fixed, accepted submission:
import re
S = input()
print('No' if re.search(r'C.*F', S) is None else 'Yes')
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

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

for i in range(n):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i
    else:
        continue

print(ans)

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

for i in range(1, n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i
    else:
        continue

print(ans)
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
def calcurate_digit_sum(num):
    digit_sum = 0
    while num > 0:
        digit_sum += num % 10
        num = num // 10
    return digit_sum

def check_harshad(num):
    digit_sum = calcurate_digit_sum(num)
    if num % digit_sum == 0:
        return("yes")
    return("no")

if __name__ == "__main__":
    N = int(input())
    print(check_harshad(N))

Fixed, accepted submission:
def calcurate_digit_sum(num):
    digit_sum = 0
    while num > 0:
        digit_sum += num % 10
        num = num // 10
    return digit_sum

def check_harshad(num):
    digit_sum = calcurate_digit_sum(num)
    if num % digit_sum == 0:
        return("Yes")
    return("No")

if __name__ == "__main__":
    N = int(input())
    print(check_harshad(N))
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, c = map(int, input().split())
a = 0
for i in range(a, b + 1):
  if i % c == 0:
    a += 1
print(a)

Fixed, accepted submission:
a, b, c = map(int, input().split())
print(b // c - (a - 1) // c)