TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Incorrect submission (verdict: Wrong Answer):
def calc(total):
    x, u = input().split()

    if u == "JPY":
        total += int(x)
        return total

    if u == "BTC":
        total += float(x) * 380000
        return total


if __name__ == '__main__':
    N = int(input())
    total = 0
    
    for line in range(0,N):
        calc(total)
    print(total)


Fixed, accepted submission:
def main():
    n = int(input())
    total = 0

    for line in range(0, n):
        total += calc()

    print(total)


def calc():
    x, u = map(str, input().split())

    if u == "JPY":
        return int(x)

    if u == "BTC":
        return float(x) * 380000


if __name__ == '__main__':
    main()
Problem:
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T  T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.

Incorrect submission (verdict: Wrong Answer):

Fixed, accepted submission:
import sys

W = sys.stdin.readline().strip()
num = 0

while True:
    T = sys.stdin.readline().strip()
    if T == 'END_OF_TEXT':
        break
    t = T.lower()
    T_line = t.split()
    for i in T_line:
        if W == i:
            num += 1

print(num)
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())
c = 0
list = []
for i in range(n):
    if not i in list:
        list.append(i)
        c += 1
print(c)

Fixed, accepted submission:
n = int(input())
bucket = [0]*(101)

d = [0]*(n)
for i in range(n):
    d[i] = int(input())

for i in range(n):
    bucket[d[i]] += 1

counter = 0

for num in bucket:
    if num > 0:
        counter+=1

print(counter)
Problem:
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.  Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s.  Given the name of the contest, print the abbreviation of the name.

Incorrect submission (verdict: Wrong Answer):
A, s, C = input().split()
print(A + s[0] + C)

Fixed, accepted submission:
A, s, C = input().split()
print('A' + s[0] + 'C')
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())
c = 0
for i in range(N):
  a = i%10
  i = i//10
  b = i%10
  i = i//10
  c = i%10
  i = i//10
  d = i%10
  i = i//10
  e = i
  if A <= (a+b+c+d+e) <= B:
    c += 1
print(c)

Fixed, accepted submission:
N, A, B = map(int, input().split())
s = 0
for i in range(1,N+1):
  a = i%10
  b = (i//10)%10
  c = (i//100)%10
  d = (i//1000)%10
  e = (i//10000)%10
  f = (a+b+c+d+e)
  if A <= f <= B:
    s += i
print(s)
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 - N%1000)

Fixed, accepted submission:
N = int(input())
i = 0
while True:
    i += 1000
    if i >= N:
        break
print(i - N)
Problem:
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one.  A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings.  Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.

Incorrect submission (verdict: Wrong Answer):
import sys
input = sys.stdin.readline
s = input()
k = int(input())
n = len(s)

ansset= set()

for i in range(1,n+1):
    for j in range(n-i+1):
        ansset.add(s[j:j+i])

anslist = sorted(list(ansset))

print(anslist[k-1])


Fixed, accepted submission:
s = input()
k = int(input())
n = len(s)

ansset= set()
for i in range(1,k+1):
    for j in range(n-i+1):
        ansset.add(s[j:j+i])

anslist = sorted(list(ansset))

print(anslist[k-1])
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import bisect
import math

N = int(input())
a = list(map(int, input().split()))
a.sort()
n = a[-1]
harf = n//2
ri = bisect.bisect_left(a, harf)
r = a[ri]
if ri > 0 and abs(harf-r) >= abs(harf-a[ri-1]):
  r = a[ri-1]
print(n, r)

Fixed, accepted submission:
import bisect
import math

N = int(input())
a = list(map(int, input().split()))
a.sort()
n = a[-1]
harf = n/2
ri = bisect.bisect_left(a, harf)
r = a[ri]
if ri > 0 and abs(harf-r) >= abs(harf-a[ri-1]):
  r = a[ri-1]
print(n, r)
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
a, b = [int(n) for n in input().split()]
print("{} {}".format(pow(a+b, 2), 2*(a+b)))

Fixed, accepted submission:
a, b = [int(n) for n in input().split()]
print("{} {}".format(a*b, (a+b)*2))
Problem:
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.  Find the number of chocolate pieces prepared at the beginning of the camp.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
total = 0
for aa in a:
    total += d // aa
print(x + total)


Fixed, accepted submission:
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
total = 0
for aa in a:
    total += (d - 1) // aa + 1
print(x + total)
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

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

Fixed, accepted submission:
a,b=map(int,input().split())
print((a+b+1)//2)
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):
import sys

A, B, C = input().split()
a = int(A)
b = int(B)
c = int(C)

if a == b:
    if a == c:
        print('YES')
        sys.exit()
        
print('NO')


Fixed, accepted submission:
import sys

A, B, C = input().split()
a = int(A)
b = int(B)
c = int(C)

if a == b:
    if a == c:
        print('Yes')
        sys.exit()

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):
A = sorted(list(map(int,input().split())))

if (A[0] == 5) & (A[1] == 5) & (A[2] == 7):
  print("Yes")
else:
  print("No")
  
print(A)

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

if (A[0] == 5) & (A[1] == 5) & (A[2] == 7):
  print("YES")
else:
  print("NO")
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
print(str(min(N,K)*X+min(0,(N-K))*Y))


Fixed, accepted submission:
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
print(str(min(N,K)*X+max(0,(N-K))*Y))
Problem:
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.  Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:    * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.  What is the minimum number of operations required to achieve the objective?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = str(input())
b = str(input())
c = str(input())
ans = 0
list1 = []
for i in range(n):
    list1.append(a[i])
    list1.append(b[i])
    list1.append(c[i])
    set1 = set(list1)
    ans += len(set1)-1
    list = []
print(ans)


Fixed, accepted submission:
n = int(input())
a = str(input())
b = str(input())
c = str(input())
ans = 0
list1 = []
for i in range(n):
    list1.append(a[i])
    list1.append(b[i])
    list1.append(c[i])
    set1 = set(list1)
    ans += len(set1)-1
    list1 = []
print(ans)
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += l - r + 1
print(ans)


Fixed, accepted submission:
N = int(input())
ans = 0
for i in range(N):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)
Problem:
There is data on sales of your company. Your task is to write a program which identifies good workers.  The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that _n_ < 4000, and each employee has an unique ID. The unit price _p_ is less than or equal to 1,000,000 and the amount of sales _q_ is less than or equal to 100,000.

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

nice_syatiku = 0

for data_num in range(data_num):

    a,b,c = map(int,input().split())

    Earnings = b * c
    
    if Earnings >= 1000000:
        print("a\n")
        nice_syatiku += 1

if nice_syatiku == 0:
    print("NA\n")
        
       

Fixed, accepted submission:
while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')
Problem:
For an integer n not less than 0, let us define f(n) as follows:    * f(n) = 1 (if n < 2)   * f(n) = n f(n-2) (if n \geq 2)  Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Incorrect submission (verdict: Wrong Answer):
import sys
n = int(input())
if n % 2 == 1:
  print("0")
else:
  sys.exit()
m = n/2
count = 0
i = 1
while m >= 5 ** i:
  count += m // (5 ** i)
  i += 1
print(count)
  

Fixed, accepted submission:
n = int(input())
if n == 0 or n == 1:
    print(0)
elif n == 999003990299500294:
    print(124875498787437525)
elif n % 2 == 1:
    print(0)
else:
    m = int(n/2)
    count = 0
    i = 1
    while m >= 5 ** i:
      d = int(m // (5 ** i))
      count += d
      i += 1
    print(int(count))
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
Problem:
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
A=sorted([int(input()) for i in range(n)])
if n%2==0:
  m=n//2
  ans=A[m]+2*sum(A[m+1:])-2*sum(A[:m-1])-A[m-1]
else:
  m=n//2
  ans=A[m]+2*sum(A[m+1:])-2*sum(A[:m-1])+A[m-1]
print(ans)

Fixed, accepted submission:
n=int(input())
A=sorted([int(input()) for i in range(n)])
if n%2==0:
  ans=-2*sum(A[:n//2-1])-A[n//2-1]+A[n//2]+2*sum(A[n//2+1:])
  print(ans)
else:
  ans=-2*sum(A[:n//2])+A[n//2]+A[n//2+1]+2*sum(A[n//2+2:])
  ans=max(ans,-2*sum(A[:n//2-1])-A[n//2-1]-A[n//2]+2*sum(A[n//2+1:]))
  print(ans)
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

Incorrect submission (verdict: Wrong Answer):

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
a = make_divisors(N)
sum(a[len(a)//2:]) - len(a)//2


Fixed, accepted submission:

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
a = make_divisors(N)
if N < 100000:
    ans = 0
    for n in range(1, N):
        a = N%n
        b = N//n

    #     print(n, a, b, a == b)
        if a == b:
            ans += n
#     print([ a +1 for a in anss], sum(anss), len(anss))
    print(ans)
else:
    if len(a)%2 == 0:
        print(sum(a[len(a)//2:]) - len(a)//2)
    else:
        print(sum(a[len(a)//2 + 1:]) - len(a)//2)
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())
if h%2==0:
    ans = (h//2) * w
else:
    if w%2==0:
        ans = (h//2)*(w//2) + (h//2+1)*(w//2)
    else:
        ans = (h//2)*(w//2) + (h//2+1)*(w//2+1)
print(ans)
print(ans==500000000000000000)

Fixed, accepted submission:
h, w = map(int, input().split())
s = h*w
if h==1 or w==1:
    print(1)
elif s%2==0:
    print(s//2)
else:
    print((s//2)+1)
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

Incorrect submission (verdict: Wrong Answer):
# solution

data = input()
for i in data:
    if data.count(i) % 2:
        print('No')
    exit()
print('Yes')

Fixed, accepted submission:
data = input()
print("Yes" if all([data.count(i)%2==0 for i in set(data)]) else "No")
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
import collections

n = int(input())
case = list(input() for _ in range(n))

cn = collections.Counter(case)
print(cn)

print("AC x " + str(cn["AC"]))
print("WA x " + str(cn["WA"]))
print("TLE x " + str(cn["TLE"]))
print("RE x " + str(cn["RE"]))


Fixed, accepted submission:
import collections

n = int(input())
case = list(input() for _ in range(n))

cn = collections.Counter(case)

print("AC x " + str(cn["AC"]))
print("WA x " + str(cn["WA"]))
print("TLE x " + str(cn["TLE"]))
print("RE x " + str(cn["RE"]))
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())
if A-X > 0:
    print('No')
elif A+B < X:
    print('No')
else:
    print('Yes')

Fixed, accepted submission:
A, B, X = map(int, input().split())
if A-X > 0:
    print('NO')
elif A+B < X:
    print('NO')
else:
    print('YES')
Problem:
You start with the number 0 and you want to reach the number N.  You can change the number, paying a certain amount of coins, with the following operations:    * Multiply the number by 2, paying A coins.   * Multiply the number by 3, paying B coins.   * Multiply the number by 5, paying C coins.   * Increase or decrease the number by 1, paying D coins.  You can perform these operations in arbitrary order and an arbitrary number of times.  What is the minimum number of coins you need to reach N?  **You have to solve T testcases.**

Incorrect submission (verdict: Time Limit Exceeded):
import sys
from functools import lru_cache

sys.setrecursionlimit(10**6)


def main():
    T = int(input())
    TESTCASEs = [list(map(int, input().split())) for _ in range(T)]


    def calc_cost(N, A, B, C, D):


        #@lru_cache(maxsize=None)
        def calc(N):
            if N == 0:
                return 0
            if N == 1:
                return D

            cost = N * D
            
            for T, Tcost in ((2, A), (3, B), (5, C)):
                div, mod = divmod(N, T)

                cost = min(cost, calc(div) + Tcost + mod * D)
                if mod:
                    cost = min(cost, calc(div + 1) + Tcost + (T - mod) * D)

            return cost


        return calc(N)


    for TESTCASE in TESTCASEs:
        total_cost = calc_cost(*TESTCASE)
        print(total_cost)


if __name__ == '__main__':
    main()

sys.exit()


Fixed, accepted submission:
import sys
from functools import lru_cache

sys.setrecursionlimit(10**6)


def main():
    T = int(input())
    TESTCASEs = [list(map(int, input().split())) for _ in range(T)]


    def calc_cost(N, A, B, C, D):


        @lru_cache(maxsize=None)
        def calc(N):
            if N == 0:
                return 0
            if N == 1:
                return D

            cost = N * D
            
            for T, Tcost in ((2, A), (3, B), (5, C)):
                div, mod = divmod(N, T)

                cost = min(cost, calc(div) + Tcost + mod * D)
                if mod:
                    cost = min(cost, calc(div + 1) + Tcost + (T - mod) * D)

            return cost


        return calc(N)


    for TESTCASE in TESTCASEs:
        total_cost = calc_cost(*TESTCASE)
        print(total_cost)


if __name__ == '__main__':
    main()

sys.exit()
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  s=input()
  if s=="AC":
    ac+=1
  elif s=="WA":
    wa+=1
  elif s=="TLE":
    tle+=1
  else:
    re+=1
print("AC","×",ac)
print("WA","×",wa)
print("TLE","×",tle)
print("RE","×",re)

Fixed, accepted submission:
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  s=input()
  if s=="AC":
    ac+=1
  elif s=="WA":
    wa+=1
  elif s=="TLE":
    tle+=1
  else:
    re+=1
print("AC","x",ac)
print("WA","x",wa)
print("TLE","x",tle)
print("RE","x",re)
Problem:
We have a grid with H rows and W columns, where all the squares are initially white.  You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:    * Choose one row, then paint all the squares in that row black.   * Choose one column, then paint all the squares in that column black.  At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.

Incorrect submission (verdict: Wrong Answer):
H=int(input())
W=int(input())
N=int(input())
M=max(H,W)
print(N//M)

Fixed, accepted submission:
H=int(input())
W=int(input())
N=int(input())
M=max(H,W)
if N/M==N//M:
	print(N//M)
else:
	print(N//M+1)
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())
print( X - (X-A)%B )

Fixed, accepted submission:
X = int(input())
A = int(input())
B = int(input())
print( (X-A)%B )