TnT/CodeNet4Repair huggingface dataset:
Problem:
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`.  You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

Incorrect submission (verdict: Wrong Answer):
chr = input()
chr_list = list(chr)
length = len(chr_list)

a, z =  chr_list[0], chr_list[length - 1]

print(a, length, z, sep = '')

Fixed, accepted submission:
chr = input()
chr_list = list(chr)
length = len(chr_list)

a, z =  chr_list[0], chr_list[length - 1]

print(a, length - 2, z, sep = '')
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):
l=list(map(int,input().split()))
participant=list(input())
passnum=l[1]+l[2]
b=0
for i in range(l[0]):
    if participant[i]=='a' and passnum>0:
        participant[i]='Yes'
        passnum-=1
    elif passnum==0:
        break
if passnum>0:
    for i in range(l[0]):
        if participant[i]=='b' and passnum>0 and b<l[2]:
            participant[i]='Yes'
            passnum-=1
            b+=1
        elif b==l[2]:
            break
        elif passnum==0:
            break
for i in range(l[0]):
    if participant[i]!='Yes':
        participant[i]='No'
for i in range(l[0]):
    print(participant[i])

Fixed, accepted submission:
l=list(map(int,input().split()))
participant=list(input())
passnum=l[1]+l[2]
b=0
for i in range(l[0]):
    if participant[i]=='a' and passnum>0:
        participant[i]='Yes'
        passnum-=1
    elif participant[i]=='b' and passnum>0 and b<l[2]:
            participant[i]='Yes'
            passnum-=1
            b+=1
    elif passnum==0:
        break
for i in range(l[0]):
    if participant[i]!='Yes':
        participant[i]='No'
for i in range(l[0]):
    print(participant[i])
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):
print(sum(range(1, int(input()))))

Fixed, accepted submission:
print(sum(range(1, int(input())+1)))
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
IN = list(map(int, input().split()))
N = IN[0]

price = round(N/1.08)
price1 = (int)(1.08 * price)

if N == price1:
    print(price1)
else:
    print(":(")

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

ans = -1

for x in range(N+1):
    if math.floor(x * 1.08) == N:
        ans = x
        break
if ans == -1:
  print(":(")
else:
  print(ans)
Problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.  To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:    * The `0` key: a letter `0` will be inserted to the right of the string.   * The `1` key: a letter `1` will be inserted to the right of the string.   * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.  Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?

Incorrect submission (verdict: Wrong Answer):
arg=input()
ans=[]
for char in arg:
  if char=='1' or char=='0':
    ans.append(char)
    print(ans)
  elif char=='B':
    if ans!=[]:
      del ans[-1]
      print(ans)
print(''.join(ans))

Fixed, accepted submission:
arg=input()
ans=[]
for char in arg:
  if char=='1' or char=='0':
    ans.append(char)
  elif char=='B':
    if ans!=[]:
      del ans[-1]
print(''.join(ans))
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
lis = [int(x) for x in input().split()]
lis.sort()
lis.reverse()
print(lis)


Fixed, accepted submission:
lis = [int(x) for x in input().split()]
lis.sort()
for i in range(2):
    print(lis[i],end = " ")
print(lis[-1])
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):
def is_even(int_num):
    if int_num % 2 == 0:
        return True
    else:
        return False


def main():
    inputs = input("input two integers for this problem: ")
    temp = inputs.split()
    if len(temp) != 2:
        print("input is invalid. input two integers.")
        exit(1)

    a, b = int(temp[0]), int(temp[1])
    if is_even(a * b):
        print("Even")
    else:
        print("Odd")


if __name__ == "__main__":
    main()


Fixed, accepted submission:
def is_even(int_num):
    if int_num % 2 == 0:
        return True
    else:
        return False


def main():
    # start = time.time()
    inputs = input().split()
    a, b = int(inputs[0]), int(inputs[1])
    if is_even(a * b):
        print("Even")
    else:
        print("Odd")

    # print((time.time() - start) * 1000.0)

if __name__ == "__main__":
    main()
Problem:
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - (T[P-1] - X) + X)

Fixed, accepted submission:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - (T[P-1] - X))
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
m, d = map(int,input().split())
cnt = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if (j % 10) * (j // 10) == i and j % 10 >= 2 and j // 10 >= 2:
            print(i, j, j % 10, j // 10)
            cnt += 1
print(cnt)

Fixed, accepted submission:
m, d = map(int,input().split())
cnt = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if (j % 10) * (j // 10) == i and j % 10 >= 2 and j // 10 >= 2:
            cnt += 1
print(cnt)
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 = max(a)
c =0
for i in a:
  if int(i) < int(b):
    c += int(i)

if c == int(b):
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
a, b, c= sorted(map(int, input().split()))
if a+b == c:
  print('Yes')
else:
  print('No')
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: Wrong Answer):
import heapq
from collections import deque

T = int(input())
for t in range(T):
    N,A,B,C,D = map(int,input().split())
    q = [(0,N)]
    heapq.heapify(q)
    seen = set()
    while q:
        cost, n = heapq.heappop(q)
        if n in seen:
            continue
        seen.add(n)
        if n == 0:
            print(cost)
            break

        heapq.heappush(q, (cost + N * D, 0))
        if n % 2 ==0:
            heapq.heappush(q, (cost + A, n // 2))
        else: 
            heapq.heappush(q, (cost + D + A, (n + 1) // 2))
            heapq.heappush(q, (cost + D + A, (n - 1) // 2))
        if n % 3 ==0:
            heapq.heappush(q, (cost + B, n // 3))
        else:
            rest = n % 3
            heapq.heappush(q, (cost + rest * D + B, (n - rest) // 3))
            heapq.heappush(q, (cost + (3-rest) * D + B, (n - rest + 3) // 3))

        if n % 5 ==0:
            heapq.heappush(q, (cost + C, n // 5))
        else:
            rest = n % 5
            heapq.heappush(q, (cost + rest * D + C, (n - rest) // 5))
            heapq.heappush(q, (cost + (5-rest) * D + C, (n - rest + 5) // 5))



Fixed, accepted submission:
import heapq

T = int(input())
for t in range(T):
    N,A,B,C,D = map(int,input().split())
    q = [(0,N)]
    heapq.heapify(q)
    seen = set()
    while q:
        cost, n = heapq.heappop(q)
        if n in seen:
            continue
        seen.add(n)
        if n == 0:
            print(cost)
            break

        heapq.heappush(q, (cost + n * D, 0))
        if n % 2 ==0:
            heapq.heappush(q, (cost + A, n // 2))
        else: 
            heapq.heappush(q, (cost + D + A, (n + 1) // 2))
            heapq.heappush(q, (cost + D + A, (n - 1) // 2))
        if n % 3 ==0:
            heapq.heappush(q, (cost + B, n // 3))
        else:
            rest = n % 3
            heapq.heappush(q, (cost + rest * D + B, (n - rest) // 3))
            heapq.heappush(q, (cost + (3-rest) * D + B, (n - rest + 3) // 3))

        if n % 5 ==0:
            heapq.heappush(q, (cost + C, n // 5))
        else:
            rest = n % 5
            heapq.heappush(q, (cost + rest * D + C, (n - rest) // 5))
            heapq.heappush(q, (cost + (5-rest) * D + C, (n - rest + 5) // 5))
Problem:
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.  We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.  At most how many people can sit on the seat?

Incorrect submission (verdict: Wrong Answer):
X, Y, Z = map(int, input().split())
print((X-Y)//(Y+Z))

Fixed, accepted submission:
X, Y, Z = map(int, input().split())
print((X-Z)//(Y+Z))
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())
R = a+b
L = c+d
if R > L:
  print('Right')
elif R < L:
  print('Left')
else:
  print('Balanced')


Fixed, accepted submission:
a, b, c, d = map(int, input().split())
L = a+b
R = c+d
if R > L:
  print('Right')
elif R < L:
  print('Left')
else:
  print('Balanced')
Problem:
Given two integers $A$ and $B$, compute the sum, $A + B$.

Incorrect submission (verdict: Wrong Answer):
sum([int(i) for i in input().split()])


Fixed, accepted submission:
print(sum([int(i) for i in input().split()]))
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

Incorrect submission (verdict: Wrong Answer):
N, M, X = map(int, input('N M X = ').split())
A = map(int, input('A_{i}(i=1,2,…,M)= ').split()) 

setA = set(A) 
s1 = range(0, X)
s2 = range(X, N+1)
a1 = set(s1) & (setA) 
a2 = set(s2) & (setA)
cost1 = len(a1)
cost2 = len(a2)

if cost1 >= cost2:
    print(cost2)
else:
    print(cost1)

Fixed, accepted submission:
N, M, X = map(int, input().split())
A = map(int, input().split()) 

setA = set(A) 
s1 = range(0, X)
s2 = range(X, N+1)
a1 = set(s1) & (setA)
a2 = set(s2) & (setA)
cost1 = len(a1)
cost2 = len(a2)

if cost1 >= cost2:
    print(cost2)
else:
    print(cost1)
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=list(map(int,input().split()))
c=H*W/2
if H%2==1 and W%2==1:
  print(c+1)
else:
  print(c)

Fixed, accepted submission:
H,W=list(map(int,input().split()))
c=int(H*W/2)
if H==1 or W==1:
  print("1")
elif H%2==1 and W%2==1:
  print(c+1)
else:
  print(c)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
a = input().split(' ')

print(min(int(i) for i in a)//2)

Fixed, accepted submission:
N = int(input())
a = input().split(' ')
c = 0


def check(a):
    global c

    for i in a:
        if int(i) % 2 == 1:
            return
    for i in a:
        a[a.index(i)] = int(i)/2
        if int(i)/2 == 1:
            c += 1
            return
    c += 1
    check(a)


check(a)
print(c)
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Incorrect submission (verdict: Wrong Answer):
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()

# a = list(map(int, input().split(' ')))

K = 'keyence'

if K in s:
    splitted = s.split(K)

    if len([spl for spl in splitted if len(spl) > 0]) > 1:
        print('NO')
    else:
        print('YES')
else:
    print('NO')


Fixed, accepted submission:
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()


# a = list(map(int, input().split(' ')))

K = 'keyence'

for i in range(len(s)):
    for j in range(len(s)):
        s1 = s[0:i]
        s2 = s[i:i + j]
        s3 = s[i + j:]

        # print(s1,s2,s3)
        if s1 == K or s2 == K or s3 == K or s1 + s2 == K or s1 + s3 == K or s2 + s3 == K:
            print('YES')
            exit()

print('NO')
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
print("????????°????????\?????????????????????>",)
print(int(input())**3)

Fixed, accepted submission:
print(int(input())**3)
Problem:
Takahashi is a user of a site that hosts programming contests.   When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows:    * Let the current rating of the user be a.   * Suppose that the performance of the user in the contest is b.   * Then, the new rating of the user will be the avarage of a and b.  For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.  Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.   Find the performance required to achieve it.

Incorrect submission (verdict: Wrong Answer):
i1 = int(input())
i2 = int(input())
print(int((i1+i2)/2))

Fixed, accepted submission:
i1 = int(input())
i2 = int(input())
print(i2*2-i1)
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<=(A+B):
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
A,B,X=map(int,input().split())
if A<=X<=(A+B):
    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):
h, w = map(int, input().split())
ans = []
if h % 2 == 0:
    ans = h / 2 * w
else:
    if w % 2 == 0:
        h_a = h//2 + 1
        ans = (h_a * 2 - 1) * w/2 
    else:
        h_a = h // 2 + 1
        ans = (h_a * 2 - 1) * (w//2) + h_a

print(ans) 
            

Fixed, accepted submission:
h, w = map(int, input().split())
if  h == 1 or w == 1:
    ans = 1
elif h % 2 == 0:
    ans = h // 2 * w
else:
    if w % 2 == 0:
        h_a = h//2 + 1
        ans = (h_a * 2 - 1) * w//2 
    else:
        h_a = h // 2 + 1
        ans = (h_a * 2 - 1) * (w//2) + h_a

print(ans)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
x = int(input("num"))
print(x**3)

Fixed, accepted submission:
x = int(input())
print(x**3)
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
n = input()
a = list(map(int,input().split(" ")))
del(a[0])
print("{0} {1}".format(min(a),max(a),sum(a)))

Fixed, accepted submission:
n = input()
a = list(map(int,input().split(" ")))
print("{0} {1} {2}".format(min(a),max(a),sum(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()
if(S in 'AC'):
 print('Yes')
else:
 print('No')

Fixed, accepted submission:
S=input()
if 'AC' in S:
 print('Yes')
else:
 print('No')
Problem:
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.  He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.  Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

Incorrect submission (verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))
dic = {}
B = []
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
for v in dic.values():
  B.append(v)
B.sort()
if len(B) <= K:
  print(0)
else:
  print(sum(B[K:]))

Fixed, accepted submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
dic = {}
B = []
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
for v in dic.values():
  B.append(v)
B.sort()
if len(B) <= K:
  print(0)
else:
  print(sum(B[:-K]))