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):
import math
a = int(input())
b = a
a = math.ceil(a/1000)
a = a * 1000
print(b-a)

Fixed, accepted submission:
import math
a = int(input())
b = a
a = math.ceil(a/1000)
a = a * 1000
print(a-b)
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

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

Fixed, accepted submission:
a,b,c = map(int, input().split())
print("No" if (c-a)*(c-b)>0 else "Yes")
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
#-*- coding:utf-8 -*-
A,B,C=map(int,input().split())
number=0
record=[]
while number%B!=C:
  number+=A
  number%=B
  record.append(number)
  if number in record:
       print('NO')
       exit()
        
print('YES')


Fixed, accepted submission:
# -*- coding:utf-8 -*-
A,B,C=map(int,input().split())

for i in range(A,A*B+1,A):
  if i %B==C:
    flag=True
    break
  else:
    flag=False
print('YES' if flag else 'NO')
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
a,b,k=map(int,(input().split()))
s=[]
for i in range(k):
    s.append(a+i)
for i in range(k):
    s.append(b-(k-i)+1)

ans=set(s)
for i in ans:
    print(i)

Fixed, accepted submission:
a,b,k=map(int,(input().split()))
s=[]
for i in range(k):
    if(a+i<=b):
        s.append(a+i)
for i in range(k):
    if(b-(k-i)+1>=a):
        s.append(b-(k-i)+1)
ans=set(s)
tmp=sorted(ans)
for i in tmp:
    print(i)
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())
i = 1
while i ** i <= x:
  i += 1
i -= 1
print(i ** i)


Fixed, accepted submission:
x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
      else:
        break
  print(ans)
Problem:
Write a program which calculates the cube of a given integer x.

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


Fixed, accepted submission:
s=input()
x=int(s)*int(s)*int(s)
print(x)
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Incorrect submission (verdict: Wrong Answer):
M = int(input())
T = M + 24
print(T)

Fixed, accepted submission:
M = int(input())
T = (24 - M) + 24
print(T)
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
S=list(input())
print(S[0::2])

Fixed, accepted submission:
S=input()
print(S[::2])
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

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

Fixed, accepted submission:
n=int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))

a.sort()

ALICE = sum(a[::2])
BOB = sum(a[1::2])

print(ALICE-BOB)

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

a.sort(reverse=True)

ALICE = sum(a[::2])
BOB = sum(a[1::2])

print(ALICE-BOB)
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()
W=["dream","dreamer","erase","eraser"]

ans="Yes"
while len(S)>0:
  if S.endswith(W[0]):
    S=S[:-len(W[0])]
  elif S.endswith(W[1]):
    S=S[:-len(W[1])]
  elif S.endswith(W[2]):
    S=S[:-len(W[2])]
  elif S.endswith(W[3]):
    S=S[:-len(W[3])]
  else:
    ans="No"
    break
    
print(ans)

Fixed, accepted submission:
S=input()
W=["dream","dreamer","erase","eraser"]

ans="YES"
while len(S)>0:
  if S.endswith(W[0]):
    S=S[:-len(W[0])]
  elif S.endswith(W[1]):
    S=S[:-len(W[1])]
  elif S.endswith(W[2]):
    S=S[:-len(W[2])]
  elif S.endswith(W[3]):
    S=S[:-len(W[3])]
  else:
    ans="NO"
    break
    
print(ans)
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
a,b,c = list(map(lambda x: int(x), input().split(" ")))

if a<b and b<c:
  print("Yes")
else:
  print("No")

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

if a<=c and c<=b:
  print("Yes")
else:
  print("No")
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):


import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    ans = []
    for i in range(K):
        ans.append(A + i)
    for i in range(K):
        ans.append(B - i)

    list(set(ans)).sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Fixed, accepted submission:


import itertools
import collections
import bisect

def main():
    A, B, K = map(int, input().split())
    ans = []
    for i in range(K):
        if A <= A + i <= B:
            ans.append(A + i)
        else:
            break
    for i in range(K):
        if A <= B - i <= B :
            ans.append(B - i)
        else:
            break

    # print(ans)
    ans = list(set(ans))
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()
Problem:
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.  Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** :    * Add 2 to a_i.   * Add 1 to b_j.

Incorrect submission (verdict: Wrong Answer):
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    print(x, a_req, b_req)
    
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()


Fixed, accepted submission:
import numpy as np


def a():
    x, y = map(int, input().split())


def b():
    n = int(input())
    a = np.asarray(list(map(int, input().split())))
    b = np.asarray(list(map(int, input().split())))
    x = b.sum() - a.sum()
    d = b - a
    a_req = 0
    b_req = 0
    for i in d:
        if i <= 0:
            b_req += i // -1
        else:
            a_req += i // 2 + i % 2
            b_req += i % 2
    
    if (a_req >= b_req and (0 < a_req + (a_req - b_req) == x)) or (a_req == 0 and b_req == 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    b()
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):
n = int(input())
jpy = 0
btc = 0
for _ in range(n):
  x,y = input().split()
  z = x.split('.')
  x = z[0]
  if y == 'JPY':
    jpy += int(x)
  else:
    btc += int(x)
print(jpy + btc * 380000.0)

Fixed, accepted submission:
n = int(input())
jpy = 0
btc = 0
for _ in range(n):
  x,y = input().split()
  if y == 'JPY':
    jpy += int(x)
  elif y == 'BTC':
    btc += float(x)
print(jpy + btc * 380000.0)
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):
s = input()
b = []

for i in s:
    if i == 'B':
        print('e')
        if len(b) != 0:
            b.pop()
    else:
        b.append(i)
    
print(''.join(b))

Fixed, accepted submission:
s = input()
b = []

for i in s:
    if i != 'B':
        b.append(i)
    elif b:
        b.pop()
    
print(''.join(b))
Problem:
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.

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

intLength = int(input())
strSentence = input()
intIndex = int(input())

strAnswer = ""
strWord = strSentence[intIndex-1]
for intIdx in range(intLength):
    print(str(intIndex) + "@" + strSentence[intIdx] + "@" + strWord)

    if strSentence[intIdx] != strWord:
        strAnswer += "*"
    else:
        strAnswer += strSentence[intIdx]

print(strAnswer)


Fixed, accepted submission:
# coding: utf-8
intLength = int(input())
strSentence = input()
intIndex = int(input())

strAnswer = ""
strWord = strSentence[intIndex-1]

for intIdx in range(intLength):
    if strSentence[intIdx] != strWord:
        strAnswer += "*"
    else:
        strAnswer += strWord

print(strAnswer)
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):

N =  int(input())
good_pattern = [int(i) for i in input().split()]
finder = False

for i in range(2 ** N):
  pattern = [int(i) for i in list(format(i,'b').zfill(N))]
  judge_arr = []
  for j in range(N):
    multiple_list = [a for a in range(N+1) if a % (j+1) == 0][1:]
    sums = 0
    for k in multiple_list:
      sums += pattern[k-1]
      
    judge = sums%2
    judge_arr.append(judge)
  print(judge_arr)
    
  if judge_arr == good_pattern:
    finder = True 
    break

if finder:
  print("Yes")

else:
  print(-1)
  

Fixed, accepted submission:
N = int(input())
mod_arr = list(map(int,input().split()))
arr = [0]*N
in_arr = []

for i in range(N,0,-1):
  if i > N//2:
    if mod_arr[i-1] == 0:
      continue
    else:
      arr[i-1] = 1
      in_arr.append(str(i))
      
  else:
    S = 0
    for j in range(2*i,N+1,i):
      S += arr[j-1]
    if S%2 == mod_arr[i-1]:
      arr[i-1] = 0
    else:
      arr[i-1] = 1
      in_arr.append(str(i))

print(len(in_arr))
print(' '.join(in_arr))
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().split())
A = list(map(int,input().split()))

t= [i for i in A if i> 0 and i< X]
s= [i for i in A if i> X and i >N]

print(min(len(t),len(s)))

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

t= [i for i in A if i> 0 and i< X]
s= [i for i in A if i> X and i<N]

print(min(len(t),len(s)))
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):
N = int(input())
A = map(int, input().split())
m = round(sum(A) / N)
print(sum(list(map(lambda x: (x-m)**2,A))))


Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
m = round(sum(A) / N)
t = sum(list(map(lambda x: (x - m) ** 2, A)))
print(t)
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 = list(map(int,input().split()))
if a.count(5) == 2 and a.count(7) == 1:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
a = list(map(int,input().split()))
if a.count(5) == 2 and a.count(7) == 1:
    print('YES')
else:
    print('NO')
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

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

Fixed, accepted submission:
a,b,c=map(int,input().split())
if((a<c and c<b) or (b<c and c<a)):
		print('Yes')
else:
		print('No')
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
#input
N,Y = map(int,input().split())
#A = list(map(int, input().split()))


ans = [-1,-1,-1]




for x in range(N):
    for y in range(N):
        for z in range(N):
            if x+y+z == N:
                list = [x,y,z]
                if Y == 10000*list[0]+5000*list[1]+1000*list[2]:
                    ans = list
                    break

print(ans)

Fixed, accepted submission:
#input
N,Y = map(int,input().split())
#A = list(map(int, input().split()))


ans = [-1,-1,-1]


for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if z >= 0:
            list = [x,y,z]
            if Y == 10000*list[0]+5000*list[1]+1000*list[2]:
                ans = list
                break
print(ans[0],ans[1],ans[2])
Problem:
You are playing the following game with Joisino.    * Initially, you have a blank sheet of paper.   * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.   * Then, you are asked a question: How many numbers are written on the sheet now?  The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Incorrect submission (verdict: Wrong Answer):
import collections

def test():
    n = int(input())
    a = [int(input()) for i in range(n)]
    b = collections.Counter(a)
    print(b)
    ans = 0
    for i in b.values():
        if i % 2 != 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    test()


Fixed, accepted submission:
import collections

def test():
    n = int(input())
    a = [int(input()) for i in range(n)]
    b = collections.Counter(a)
    ans = 0
    for i in b.values():
        if i % 2 != 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    test()
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+b >= x:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,x = map(int, input().split())
if a > x:
    print("NO")
elif a+b >= x:
    print("YES")
else:
    print("NO")
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
from itertools import product
import numpy as np
a = int(input())
b = int(input())
c = int(input())
x = int(input())

a = ', '.join([str(sum(el)) for el in 
               product(
                   np.arange(a+1)*500, np.arange(b+1)*100, np.arange(c+1)*50
               )]) + ', '
print(a.count(
    ', {},'.format(x)
))

Fixed, accepted submission:
from itertools import product
import numpy as np
a = int(input())
b = int(input())
c = int(input())
x = int(input())

a = sum([sum(el)==x for el in 
               product(
                   np.arange(a+1)*500, np.arange(b+1)*100, np.arange(c+1)*50
               )])
print(a)
Problem:
_ButCoder Inc._ runs a programming competition site called _ButCoder_. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called _Kaiden_ ("total transmission"). Note that a user's rating may become negative.  Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).  According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?

Incorrect submission (verdict: Wrong Answer):
k,a,b=map(int,input().split())
ans=0
k-=a
if a-b<=0:
  print(-1)
elif k<=0:
  print(1)
else:
  print((k-1)//(a-b)+2)

Fixed, accepted submission:
k,a,b=map(int,input().split())
ans=0
k-=a
if k<=0:
  print(1)
elif a-b<=0:
  print(-1)
else:
  print(2*((k-1)//(a-b)+1)+1)
Problem:
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.  We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.  Find the maximum number of robots that we can keep.

Incorrect submission (verdict: Wrong Answer):
from operator import itemgetter
N = int(input())
arms = []
finishtime = float('-inf')
for i in range(N):
    x,l = map(int,input().split())
    arms.append((x-l,x+l))
arms.sort(key=itemgetter(1))
cnt=0
for L,R in arms:
    if R >= finishtime:
        cnt+=1
        finishtime = R
print(cnt)

Fixed, accepted submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter



N = int(readline())
m = map(int,read().split())
XL = zip(m,m)

LR = [(x-l,x+l) for x,l in XL]
LR.sort(key = itemgetter(1))

INF = 10 ** 18
prev_R = -INF
cnt = 0
for L,R in LR:
    if prev_R > L:
        continue
    cnt += 1
    prev_R = R

print(cnt)