TnT/CodeNet4Repair huggingface dataset:
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())
a = n % 1000
if a == 0:
    print(0)
else:
    print(1000-n)

Fixed, accepted submission:
n = int(input())
a = n % 1000
if a == 0:
    print(0)
else:
    print(1000-a)
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())
print("Yes" if a + b <= c else "No")  

Fixed, accepted submission:
a, b, c = map(int, input().split())
print("Yes" if a + b >= c else "No")
Problem:
N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.

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

tmax = A[0]
humidai = 0
humidai_sum = 0

for a in A :
  print("tmax:"+str(tmax)+"_a:"+str(a))
  if tmax > a:
    humidai = tmax - a
    humidai_sum += humidai
    tmax = humidai + a
  else :
    tmax = a
    
print(humidai_sum)

Fixed, accepted submission:
N = int(input())
A = [int(i) for i in input().split()]

tmax = A[0]
humidai = 0
humidai_sum = 0

for a in A :
  if tmax > a:
    humidai = tmax - a
    humidai_sum += humidai
  else :
    tmax = a
    
print(humidai_sum)
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())
c=int((a+b)*h/2)
print(c)
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
a, b = input().split()
m = int(a+b)
m_hei = int(m**0.5)
m_mult = m_hei*m_hei
print(m)
if m_mult == m:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a, b = input().split()
m = int(a+b)
m_hei = int(m**0.5)
m_mult = m_hei*m_hei
if m_mult == m:
    print("Yes")
else:
    print("No")
Problem:
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.   There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.   Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.

Incorrect submission (verdict: Wrong Answer):
list = [0]
n = int(input())
list *= n
max = 0
min = 1000
for i in range(n):
    if list[i]<min:
        min = list[i]
    if max<list[i]:
        max = list[i]
print(max-min)


Fixed, accepted submission:
nums = [0]
n = int(input())
nums *= n
nums = list(map(int,input().split()))
max = 0
min = 1000
for i in range(n):
    if nums[i]<min:
        min = nums[i]
    if max<nums[i]:
        max = nums[i]
print(max-min)
Problem:
You are given a string S.  Takahashi can insert the character `A` at any position in this string any number of times.  Can he change S into `AKIHABARA`?

Incorrect submission (verdict: Wrong Answer):

S = input() 
if not S in "AKIHABARA":
	print("NO")
	exit(0)


string =  ""
count = 0

for i in S:
	if i != 'A':
		string += i


if string == "KIHBR":
	print("YES")

else:
	print("NO")


Fixed, accepted submission:

S = input() 
if((not S in "AKIHABARA") and (not S in "AKIHBARA") and (not S in "AKIHBRA") and (not S in "AKIHABRA")):
	print("NO")
	exit(0)


string =  ""
count = 0

for i in S:
	if i != 'A':
		string += i


if string == "KIHBR":
	print("YES")

else:
	print("NO")
Problem:
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.  You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.  However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.  For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
li = list(map(int,input().split()))
sumpo = 0
li.append(0)
sumpo += abs(li[0])
for i in range(0,n):
    sumpo += abs(li[i]-li[i+1])
if n == 1:
    print(2*abs(li[0]))
else:
    for i in range(n):
        if(i == 0):
            if(li[0]<0 and li[1]<0):
                if(li[0]>li[1]):
                    print(sumpo)
                else:
                    print(sumpo-(li[1]-li[0])*2)
            else:
                if(li[0]>li[1]):
                    print(sumpo-(li[0]-li[1])*2)
                else:
                    print(sumpo)
        elif(i==n-1):
            if(li[n-1]<0 and li[n-2]<0):
                if(li[n-1]>li[n-2]):
                    print(sumpo)
                else:
                    print(sumpo-(li[n-2]-li[n-1])*2)
            else:
                if(li[n-1]>li[n-2]):
                    print(sumpo-(li[n-1]-li[n-2])*2)
                else:
                    print(sumpo)
        else:
            if(li[i-1]<=li[i]<=li[i+1]):
                print(sumpo)
            elif(li[i-1]>=li[i]>=li[i+1]):
                print(sumpo)
            else:
                print(sumpo-2*abs(li[i-1]-li[i]))

        


Fixed, accepted submission:
n = int(input())
li = list(map(int,input().split()))
lis = []
lis.append(0)
for hoge in li:
    lis.append(hoge)
lis.append(0)
sumpo = 0
sumpo += abs(li[0])
for i in range(1,n+1):
    sumpo += abs(lis[i]-lis[i+1])
for i in range(1,n+1):
    print(sumpo + abs(lis[i+1]-lis[i-1]) - (abs(lis[i]-lis[i-1])+abs(lis[i+1]-lis[i])))
Problem:
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once.  You are given the sequence _A_ and _q_ questions where each question contains _M i_.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

import random
import sys
import os
import pprint




n = int(input())
A = list(map(int, input().split()))


row_num = len(A)
column_num = 2000
T = [[None for i in range(column_num)] for j in range(row_num)]
#pprint.pprint(T)


def solve(i, m):
    # out of index
    if i >= len(A):
        return False
    if m < 0:
        return False

    if T[i][m] is not None:
        return T[i][m]

    if m == 0:
        T[i][m] = True
    
    #    T[i][m] = False
    elif solve(i+1, m):
        T[i][m] = True
    elif solve(i+1, m - A[i]):
        T[i][m] = True
    else:
        T[i][m] = False
    return T[i][m]

test_num = int(input())
test_values = map(int, input().split())
for v in test_values:
    result = solve(0, v)
    if result is True:
        print('yes')
    else:
        print('no')

Fixed, accepted submission:
# -*- coding: utf-8 -*-

import sys
import os


n = int(input())
A = list(map(int, input().split()))


q = int(input())
M = list(map(int, input().split()))


memo = [[None for i in range(2000)] for j in range(n + 1)]

def solve(i, m):
    if memo[i][m] is not None:
        return memo[i][m]
    #print('i', i, 'm', m)

    
    
    if m == 0:
        return True
    elif i >= n:
        return False
    else:
        # Devide and Conquer

        
        res0 = solve(i + 1, m)
        
        res1 = solve(i + 1, m - A[i])

        if res0 or res1:
            memo[i][m] = True
            return True
        else:
            memo[i][m] = False
            return False


# main
for m in M:
    result = solve(0, m)
    if result:
        print('yes')
    else:
        print('no')
Problem:
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.  How many grams of sand will the upper bulb contains after t seconds?

Incorrect submission (verdict: Wrong Answer):
A = list(map(int, input().split()))
print(min(0, A[0]-A[1]))

Fixed, accepted submission:
A = list(map(int, input().split()))
print(max(0, A[0]-A[1]))
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
s=input()
count=0
for i in range(n):
  str_1=s[0:i]
  str_2=s[i+1:n]
  if count<len(set(str_1)&set(str_2)):
    count=len(set(str_1)&set(str_2))
print(count)    

Fixed, accepted submission:
n=int(input())
s=input()
count=0
for i in range(n):
  str_1=s[0:i-1]
  str_2=s[i-1:n]
  if count<len(set(str_1)&set(str_2)):
    count=len(set(str_1)&set(str_2))
print(count)
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
from itertools import permutations
from sys import exit
S=input()
for s in permutations('abc'):
  if S == s:
    print('Yes')
    exit(0)
print('No')

Fixed, accepted submission:
from itertools import permutations
from sys import exit
S=input()
for s in permutations('abc'):
  if S == ''.join(s):
    print('Yes')
    exit(0)
print('No')
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
str = input()
a = int(str[1:])
b = int(str[-1:])
print("Yes") if a % 111 == 0 or b % 111 == 0 else print("No")


Fixed, accepted submission:
str = input()
a = int(str[:3])
b = int(str[-3:])
print("Yes") if a % 111 == 0 or b % 111 == 0 else print("No")
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,b,c=map(int,input().split())
if a+b==c:
    print("Yes")
if a+c==b:
    print("Yes")
if b+c==a:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,c=map(int,input().split())
if a+b==c:
    print("Yes")
elif a+c==b:
    print("Yes")
elif b+c==a:
    print("Yes")
else:
    print("No")
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
N,K=map(int,input().split())
print('YNeos'[2*K-1>N::2])

Fixed, accepted submission:
N,K=map(int,input().split())
print('YNEOS'[2*K-1>N::2])
Problem:
Snuke has N sticks. The length of the i-th stick is l_i.  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.

Incorrect submission (verdict: Wrong Answer):
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

sorted(L, reverse=True)
a = 0
for i in range(K):
    a += L[i]
print(a)


Fixed, accepted submission:
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

l = sorted(L, reverse=True)
a = 0
for i in range(K):
    a += l[i]
print(a)
Problem:
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.  You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing.  The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.

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

for i in range(0, N):
    for j in range(0, N):
        if i != j:
            if j<i:
                if S[j] == "W":
                    A[i]+=1
                
            if j>i:
                if S[j] == "E":
                    A[i]+=1

ans=0
for i in range(0, N-1):
    if A[i] > A[i+1]:
        A[i] = A[i+1]
        ans = i + 1

print(ans+1)

Fixed, accepted submission:
N = int(input())
S = str(input())
W=[0] * N
E=[0] * N

for i in range(1, N):
    if S[i-1] == "W":
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in range(N-2, -1, -1):
    if S[i+1] == "E":
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

tmp=W[0]+E[0]
for i in range(1, N):
    if tmp > W[i]+E[i]:
        tmp = W[i]+E[i]

print(tmp)
Problem:
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them.  He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).  Find the minimum total cost to achieve his objective.

Incorrect submission (verdict: Wrong Answer):
import statistics

n = int(input())
a = list(map(int, input().split()))
med = statistics.median(a)

ans = 0

for i in a:
    ans += (med - i)**2
    
print(ans)

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

if len(set(a)) == 1:
    print(0)
    exit()

mi = min(a)
ma = max(a)

min_sum = 1000000000000000000

for i in range(mi, ma+1):
    sum = 0
    for j in range(n):
        sum += (a[j] - i)**2
    if sum < min_sum:
        min_sum = sum

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

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

Fixed, accepted submission:
x = input('')
print (int(x)**3)
Problem:
Snuke loves working out. He is now exercising N times.  Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i.  Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
p = 1
for i in range(n):
	p *= i
print(i % 10**9+7)

Fixed, accepted submission:
n = int(input())
p = 1
for i in range(1, n+1):
  	p = p*i % (10**9 + 7)
print(p)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
x=input()
print(x)


Fixed, accepted submission:
x=input()
a=int(x)*int(x)*int(x)
print(a)
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):
S = [i for i in list(input())]
k = ['k', 'e', 'y', 'e', 'n', 'c', 'e'] + ['_']*100
N = len(S)
m = 0;c=0
flag=False
for i in S:
    if i == k[m]:
        m+=1
        if flag:
            flag = False
    else:
        if not flag: c+=1
        flag=True

if c<=1 and m==6: print('YES')
else: print('NO')

Fixed, accepted submission:
S=[i for i in list(input())];N=len(S);k=['k','e','y','e','n','c','e']
for d in range(N-6):
    for i in range(N-d+1):
        s=S[:i]+S[i+d:]
        if s==k:
            print('YES');quit()
print('NO')
Problem:
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
a **= .5
b **= .5
c **= .5

print("YES" if a + b < c else "NO")


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

print("Yes" if c - b - a > 0 and (c - b - a) ** 2 > 4 * a * b else "No")
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
S=list(input())
n=len(S)
ans=0

for i in range(2**n):
    stack=""
    l=[]
    for j in range(n):
        stack=stack+S[j]
        if ((i >> j) & 1)or j==n-1:
            l.append(int(stack))
            stack=""
    ans+=sum(l)
    if len(l)==len(S):
        break
    print(l)
print(ans)

Fixed, accepted submission:
S=list(input())
n=len(S)
ans=0
for i in range(2**(n-1)):
    stack=""
    l=[]
    for j in range(n):
        stack=stack+S[j]
        if ((i >> j) & 1)or j==n-1:
            l.append(int(stack))
            stack=""
    ans+=sum(l)
print(ans)
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):
S = input().split()

count1 = 0
count2 = 0

for s in S: 
  if s == "5":
    count1 += 1
  elif s == "7":
    count2 += 1
  
if count1 == 2 and count2 == 1:
  print("Yes")
else:
  print("No")
    

Fixed, accepted submission:
S = input().split()

count1 = 0
count2 = 0

for s in S: 
  if s == "5":
    count1 += 1
  elif s == "7":
    count2 += 1
  
if count1 == 2 and count2 == 1:
  print("YES")
else:
  print("NO")
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,b,c = map(int,input().split())
half = int((a+b+c) /2)

if half == a+b or half == a+c or half == b+c:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
a,b,c = map(int,input().split())
half = int((a+b+c) /2)

if half == a+b or half == a+c or half == b+c:
    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):

Fixed, accepted submission:
H, W = map(int, input().split())

HW = H * W
if H == 1 or W == 1:
    ans = 1
elif HW % 2 == 0:
    ans = HW // 2
else:
    ans = (HW + 1) // 2

print(ans)
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):
import collections
N=int(input())
table=collections.defaultdict(int)
a=list(map(int,input().split()))
for i,x in enumerate(a):
  table[i+1]=x
ans=0
for x in table:
  b=table[x]
  if table[b]==x:
    ans+=1
print(ans)

Fixed, accepted submission:
import collections
N=int(input())
table=collections.defaultdict(int)
a=list(map(int,input().split()))
for i,x in enumerate(a):
  table[i+1]=x
ans=0
for x in table:
  b=table[x]
  if table[b]==x:
    ans+=1
    table[x]=0
print(ans)
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

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

if S.count('o') >= 8:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
S = input()

if S.count('o') >= 8 - (15 - len(S)):
    print('YES')
else:
    print('NO')
Problem:
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:    * Question 1: Are you subscribing to Newspaper X?   * Question 2: Are you subscribing to Newspaper Y?  As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.  What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?  Write a program to answer this question.

Incorrect submission (verdict: Wrong Answer):
n,a,b=map(int,input().split())
print(min(a,b),min(a,b)-(n-max(a,b)))

Fixed, accepted submission:
n,a,b=map(int,input().split())
print(min(a,b),max(0,a+b-n))
Problem:
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.

Incorrect submission (verdict: Wrong Answer):
numdict = dict()
while True:
	try:
		num = input()
		if num not in numdict:
			numdict[num] = 0
		else:
			numdict[num] += 1
	except EOFError:
		break
most = max(numdict.values())
for key in numdict:
	if most == numdict[key]:
		print(key)

Fixed, accepted submission:
numdict = dict()
while True:
	try:
		num = input()
		if num not in numdict:
			numdict[num] = 0
		else:
			numdict[num] += 1
	except EOFError:
		break
most = max(numdict.values())
mostlist = list()
for key in numdict:
	if most == numdict[key]:
		mostlist.append(int(key))
mostlist.sort()
for item in mostlist:
	print(item)