TnT/CodeNet4Repair huggingface dataset:
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):
N = int(input())
L = []
for i in range(N):
    x = [int(x) for x in input().split()]
    L.append(x)
for i in range(len(L)):
    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
S =[]
Q = sorted(L)
for i in range(0,len(Q)-1):
    if Q[i+1][0] >=Q[i][1] :
        S.append([Q[i][0],Q[i][1]])
        print(S)
print(len(S)+1)

Fixed, accepted submission:
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]
RL = [[0, 0] for _ in range(N)]
for i in range(N):
    left = XL[i][0] - XL[i][1]
    right = XL[i][0] + XL[i][1]
    RL[i][0] = left
    RL[i][1] = right
 
RL.sort(key=lambda x: x[1])
now_right = RL[0][1]
cnt = 0
for i in range(1, N):
    if now_right <= RL[i][0]:
        now_right = RL[i][1]
    else:
        cnt += 1
print(N - cnt)
Problem:
In this problem, we only consider strings consisting of lowercase English letters.  Strings s and t are said to be **isomorphic** when the following conditions are satisfied:    * |s| = |t| holds.   * For every pair i, j, one of the following holds:     * s_i = s_j and t_i = t_j.     * s_i \neq s_j and t_i \neq t_j.  For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not.  A string s is said to be in **normal form** when the following condition is satisfied:    * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.  For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`.  You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.

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

tmp_list = list('a' * n)
num_list = [97] * n
target = n - 1
tmp_target=n-1
while tmp_target>0:
    print("".join(list(map(chr, num_list))))
    if num_list[target-1] >= num_list[target]:
        num_list[target] += 1
    else:
        num_list[target]=97
        tmp_target=target-1
        while tmp_target>0:
            if num_list[tmp_target-1] >=num_list[tmp_target]:
                num_list[tmp_target]+=1
                break
            else:
                num_list[tmp_target]=97
                tmp_target-=1


Fixed, accepted submission:
n = int(input())
num_list = [97] * n
target = n - 1
tmp_target = n - 1
max_num = 97
if n==1:
    print('a')
while tmp_target > 0:
    print("".join(list(map(chr, num_list))))
    if max(num_list[0:target:]) >= num_list[target]:
        num_list[target] += 1
    else:
        num_list[target] = 97
        tmp_target = target - 1
        while tmp_target > 0:
            if max(num_list[0:tmp_target:]) >= num_list[tmp_target]:
                num_list[tmp_target] += 1
                break
            else:
                num_list[tmp_target] = 97
                tmp_target -= 1
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int, input().split())
S=[["." for _ in range(w+2)]]
S+=[["."]+[i for i in input()]+["."]for _ in range(h)]
S+=[["." for _ in range(w+2)]]
print(S)
for i in range(1, h+1):
    l=""
    for j in range(1, w+1):
        if S[i][j]=="#":
            l+="#"
        else:
            # l+=str(int(S[i][j]=="."))
            l+=str(sum(S[i+n][j+m]=="#" for n in range(-1, 2, 1) for m in range(-1, 2, 1)))
    print(l)

Fixed, accepted submission:
h,w = map(int, input().split())
S=[["." for _ in range(w+2)]]
S+=[["."]+[i for i in input()]+["."]for _ in range(h)]
S+=[["." for _ in range(w+2)]]
for i in range(1, h+1):
    l=""
    for j in range(1, w+1):
        if S[i][j]=="#":
            l+="#"
        else:
            l+=str(sum(S[i+n][j+m]=="#" for n in range(-1, 2, 1) for m in range(-1, 2, 1)))
    print(l)
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

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

r = 1
num = 0

while num >= X:
    num += r
    r += 1

print(r-1)

Fixed, accepted submission:
X = int(input())

r = 1
num = 0

while num < X:
    num += r
    r += 1

print(r-1)
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

for i in range(t):
    if b<a:
        a-=v
        b-=w
    else:
        a+=v
        b+=w
    if a==b:
        print("Yes")
        exit()
print("No")


Fixed, accepted submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if w>=v:
    print("NO")
else:#v>w
    dif=v-w
    if dif*t>=abs(a-b):
        print("YES")
    else:
        print("NO")
Problem:
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.

Incorrect submission (verdict: Wrong Answer):
s = list(input())
size = len(s)
count = 0 
ans = {}
for i in s:
    
    if i in ans.keys() :
        count += 1
    else : 
        ans[i] = 1
        pass
if count == 0 : print("YES")
else: print("NO")

Fixed, accepted submission:
s = list(input())
size = len(s)
count = 0 
ans = {}
for i in s:
    
    if i in ans.keys() :
        count += 1
    else : 
        ans[i] = 1
        pass
if count == 0 : print("yes")
else: print("no")
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(reverse=True)
alice = sum([i for i in a if i%2 == 0])
bob = sum([i for i in a if i%2 == 1])
print(alice-bob)


Fixed, accepted submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = sum([a[i] for i in range(0,n,2)])
bob = sum([a[i] for i in range(1,n,2)])
print(alice-bob)
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):
s=input();print(sorted(s[i:i+j]for i in range(len(s))for j in range(6))[int(input())])

Fixed, accepted submission:
s=input();print(sorted({s[I//6:I//6+I%6]for I in range(30000)})[int(input())])
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
print(((-1+(1+8*int(input()))**0.5)//2+1))     

Fixed, accepted submission:
def main():
    x = int(input())
    k = int(x ** .5)

    i = 0
    while True:
        p = i * (i + 1) // 2
        if p >= x:
            print(i)
            break
        i += 1


if __name__ == '__main__':
    main()
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

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


def main():
    """Function."""
    n = int(input())
    k = int(input())

    flag = 0
    temp = 1
    for _ in range(n):
        print(_, temp)
        if flag == 0:
            if temp < k:
                temp = temp * 2
            else:
                temp += k
                flag = 1

        elif flag == 1:
            temp += k
    print(temp)


if __name__ == "__main__":
    main()


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


def main():
    """Function."""
    n = int(input())
    k = int(input())

    flag = 0
    temp = 1
    for _ in range(n):
        if flag == 0:
            if temp < k:
                temp = temp * 2
            else:
                temp += k
                flag = 1

        elif flag == 1:
            temp += k
    print(temp)


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

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 17:04:29 2017

@author: goto
"""
y=0
x=input()
print(type(x))
x_int=[int(x)for i in list(x)]
for i in range(len(x_int)):
    y+=x_int[i]
    
if int(x)/y==0:
    print("Yes")
else:
    print("No")
    




Fixed, accepted submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 17:04:29 2017

@author: goto
"""
y=0
x=input()

x_int=[int(i)for i in list(str(x))]
for i in range(len(x_int)):
    y+=x_int[i]
    

if int(x)%y==0:
    print("Yes")
else:
    print("No")
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
N, A, B = list(map(int, input().split()))
S = list(input())
a = 0
b = 0
for i in range(N):
	if S[i] == "a":
		if a < A + B:
			print("Yes")
		else:
			print("No")
		a += 1
	elif S[i] == "b":
		if a + b < A + B and  b < B:
			print("Yes")
		else:
			print("No")
		b += 1
	else:
		print("No")

Fixed, accepted submission:
N, A, B = list(map(int, input().split()))
S = list(input())
a = 0
b = 0
ps = 0
for i in range(N):
	if S[i] == "a":
		if ps < A + B:
			print("Yes")
			ps += 1
		else:
			print("No")
		a += 1
	elif S[i] == "b":
		if ps < A + B and  b < B:
			print("Yes")
			b += 1
			ps += 1
		else:
			print("No")
		
	else:
		print("No")
Problem:
Print the K-th element of the following sequence of length 32:                1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51

Incorrect submission (verdict: Wrong Answer):
K=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

a[K-1]

Fixed, accepted submission:
K=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K-1])
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())

amari = n % 1000

if amari != 0:
  print(1000 - amari)
else:
  print(0)
Problem:
VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.  Our store uses the following rules to calculate the after-tax prices.    * When the VAT rate is _x_ %, for an item with the before-tax price of _p_ yen, its after-tax price of the item is _p_  (100+ _x_ ) / 100 yen, fractions rounded off.    * The total after-tax price of multiple items paid at once is the sum of after-tax prices of the items.   The VAT rate is changed quite often. Our accountant has become aware that "different pairs of items that had the same total after-tax price may have different total after-tax prices after VAT rate changes." For example, when the VAT rate rises from 5% to 8%, a pair of items that had the total after-tax prices of 105 yen before can now have after-tax prices either of 107, 108, or 109 yen, as shown in the table below.  Before-tax prices of two items| After-tax price with 5% VAT| After-tax price with 8% VAT   ---|---|---   20, 80| 21 + 84 = 105| 21 + 86 = 107   2, 99| 2 + 103 = 105| 2 + 106 = 108   13, 88| 13 + 92 = 105| 14 + 95 = 109       Our accountant is examining effects of VAT-rate changes on after-tax prices. You are asked to write a program that calculates the possible maximum total after-tax price of two items with the new VAT rate, knowing their total after- tax price before the VAT rate change.

Incorrect submission (verdict: Wrong Answer):

Fixed, accepted submission:
from math import floor
while(True):
    x,y,s=map(int,input().split())
    if (x,y,s)==(0,0,0):
        quit()
    ans=0
    for i in range(1,s):
        j=s-floor(i*(100+x)/100)
        if j<1:
            continue
        j=floor((j+1)*(100/(100+x)))
        for k in [j-1,j]:
            if floor(i*(100+x)/100)+floor(k*(100+x)/100)==s:
                ans=max(ans,floor(i*(100+y)/100)+floor(k*(100+y)/100))
    print(ans)
Problem:
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 SelectionSort(A) 1 for i = 0 to A.length-1 2     mini = i 3     for j = i to A.length-1 4         if A[j] < A[mini] 5             mini = j 6     swap A[i] and A[mini]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.

Incorrect submission (verdict: Wrong Answer):
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(0, element_num - 1):
    max_val = elements[i + 1]
    max_index = i + 1
    for j in range(i + 1, element_num):
      if max_val < elements[j]:
        max_val = elements[j]
        max_index = j
    if elements[i] > elements[max_index]:
      elements[i], elements[max_index] = elements[max_index], elements[i]
      swap_count += 1

  print(' '.join(list(map(str, elements))))
  print(swap_count)

  return 0


if __name__ == '__main__':
  main()

Fixed, accepted submission:
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(0, element_num - 1):
    min_val = elements[i + 1]
    min_index = i + 1
    for j in range(i + 1, element_num):
      if elements[j] < min_val:
        min_val = elements[j]
        min_index = j
    if elements[i] > elements[min_index]:
      elements[i], elements[min_index] = elements[min_index], elements[i]
      swap_count += 1

  print(' '.join(list(map(str, elements))))
  print(swap_count)

  return 0


if __name__ == '__main__':
  main()
Problem:
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?

Incorrect submission (verdict: Wrong Answer):
s = input()
l= len(s)-2
x=s[0]
y=s[-1]
print(x+str(l)+y)

Fixed, accepted submission:
n,m=map(int,input().split())
print((n-1)*(m-1))
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):
s = input().split()
print(s[0]+s[1]+s[2])

Fixed, accepted submission:
s = input().split()
print(s[0][0]+s[1][0]+s[2][0])
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()

while True:
    if len(S) == 0:
        print("Yes")
        break
    elif S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print("No")
        break

Fixed, accepted submission:
S = input()

while True:
    if len(S) == 0:
        print("YES")
        break
    elif S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print("NO")
        break
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
N = int (input ())
z = 1
l = []
while True:
  l.append ((2+z)**2-(1+z+z))
  
  if N <= (2+z)**2-(1+z+z):
    break
  else:
    print (z)
    z += 1

Fixed, accepted submission:
N = int ( input())
ans = [0]*N
for x in range (1,101):
  for y in range (1,101):
    for z in range (1,101):
      m = (x+y+z)**2-(x*y+y*z+z*x)
      if m <= N:
        ans[m-1] += 1
for i in ans:
  print(i)
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):
def inpn(): return int(input())
N, K, X, Y = inpn(), inpn(), inpn(), inpn()
if K <= N:
    print(K*X)
else:
    print(N*X+(N-K)*Y)

Fixed, accepted submission:
def inpn(): return int(input())
N, K, X, Y = inpn(), inpn(), inpn(), inpn()
if N <= K:
    print(N*X)
else:
    print(K*X+(N-K)*Y)
Problem:
Compute A \times B, truncate its fractional part, and print the result as an integer.

Incorrect submission (verdict: Wrong Answer):
A, B = input().split()
A = int(A)
B = float(B)
print(A)
print(B)
C = A * B
C = int(C)
print(C)

Fixed, accepted submission:
import decimal

A, B = input().split()
A = int(A)
B = decimal.Decimal(B)
C = A * B
C = int(C)
print(C)
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):
s = input()
initial = s[0]
final = s[len(s) - 1]
print(initial + str(len(s)) + final)


Fixed, accepted submission:
s = input()
initial = s[0]
final = s[len(s) - 1]
print(initial + str(len(s)-2) + final)