TnT/CodeNet4Repair huggingface dataset:
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):
icase=0    
if icase==0:
    a,b,c=map(int,input().split())
    if a<=c and c<=b:
        print("YES")
    else:
        print("NO")
    

Fixed, accepted submission:
icase=61
if icase==61:
    a,b,c=map(int,input().split())
    if a<=c and c<=b:
        print("Yes")
    else:
        print("No")
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 = input()


def judge():
    L = len(S)
    keyence = 'keyence'
    if S[0] != 'k':
        if S[-7:] != 'keyence':
            return False
        else:
            return True
    else:
        for i in range(8):
            if S[0:i] == keyence[0:i] and S[L-(7-i):L] == keyence[i:7]:
                return True
        return False


def main():
    print(judge())

if __name__ == '__main__':
    main()


Fixed, accepted submission:
S = input()


def judge():
    L = len(S)
    keyence = 'keyence'
    if S[0] != 'k':
        if S[-7:] != 'keyence':
            return False
        else:
            return True
    else:
        for i in range(8):
            if S[0:i] == keyence[0:i] and S[L-(7-i):L] == keyence[i:7]:
                return True
        return False


def main():
    if judge():
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
Problem:
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
S = set()
D = dict()
for _ in range(n):
    a, b = map(int, input().split())
    if a in S:
        D[a] += b
    else:
        S.add(a)
        D[a] = b
L = sorted(S)
cnt=0
for l in L:
    if cnt >= k:
        print(l)
        break
    cnt += D[l]

Fixed, accepted submission:
n, k = map(int, input().split())
S = set()
D = dict()
for _ in range(n):
    a, b = map(int, input().split())
    if a in S:
        D[a] += b
    else:
        S.add(a)
        D[a] = b
L = sorted(S)
cnt = 0
for l in L:
    cnt += D[l]
    if cnt >= k:
        print(l)
        break
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):
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product

#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    print(N % 1000)

if __name__ == "__main__":
    run()

Fixed, accepted submission:
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product

#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    a = (N + 999) // 1000
    print(a * 1000 - N)

if __name__ == "__main__":
    run()
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):
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = -1


N, K = map(int, input().split())


A = [int(i) for i in input().split(' ')]

bag = {}

for x in A:
	if x in bag:
		bag['x'+str(x)]+=1
	else:
		bag['x'+str(x)] = 1

debug(bag)
L = sorted(bag.items(),key= lambda x:x[1])
debug(L)
cnt = len(L) - K

if cnt > 0:
	result = sum(y[1] for y in L[0:K])
	debug([y[1] for y in L[0:K]])
else:
	result = 0


print(result)


Fixed, accepted submission:
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = 0


N, K = map(int, input().split())


A = [int(i) for i in input().split(' ')]

bag = {}

for x in A:
	if 'x'+str(x) in bag:
		bag['x'+str(x)]+=1
	else:
		bag['x'+str(x)] = 1

debug(bag)
L = sorted(bag.items(),key= lambda x:x[1])
debug(L,len(L),K)
cnt = len(L) - K

if cnt > 0:
	result = sum(y[1] for y in L[0:cnt])
	debug([y[1] for y in L[0:cnt]])
else:
	result = 0


print(result)
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
H,W = map(int,input().split())
List = []
for _ in range(H):
  S = input()
  List.append(S)
print('*'*(W+2))
for i in range(H):
  print('*'.strip(),end='')
  print(List[i].strip(),end='')
  print('*')
print('*'*(W+2))

Fixed, accepted submission:
H,W = map(int,input().split())
List = []
for _ in range(H):
  S = input()
  List.append(S)
print('#'*(W+2))
for i in range(H):
  print('#'.strip(),end='')
  print(List[i].strip(),end='')
  print('#')
print('#'*(W+2))
Problem:
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:    * For any two vertices painted in the same color, the distance between them is an even number.  Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
uvw=[list(map(int,input().split())) for _ in range(N-1)]
q=[[] for _ in range(N)]
max=10**15
dist=[0]+[max for i in range(N-1)]
for i in range(N-1):
    q[uvw[i][0]-1].append((uvw[i][1],uvw[i][2]))
    q[uvw[i][1]-1].append((uvw[i][0],uvw[i][2]))
now=0
now_d=0

while(True):
    print(q)
    if q[q[now][-1][0]-1]==[]:
        q[now].pop()
        if q[now]==[]:
            break
    posi=q[now][-1]
    if dist[posi[0]-1]==max:
        dist[posi[0]-1]=now_d+posi[1]
    now_d=dist[posi[0]-1]
    q[now].pop()
    now=posi[0]-1
    posi=q[posi[0]-1][0]

print(dist)
    
for i in range(N):
    if dist[i]%2==0:
        print(0)
    else:
        print(1)

Fixed, accepted submission:
N=int(input())
uvw=[list(map(int,input().split())) for _ in range(N-1)]
q=[[] for _ in range(N)]
max=10**15
dist=[0]+[max for i in range(N-1)]
for i in range(N-1):
    q[uvw[i][0]-1].append((uvw[i][1]-1,uvw[i][2]))
    q[uvw[i][1]-1].append((uvw[i][0]-1,uvw[i][2]))
now=0
now_d=0

while(True):
    if q[q[now][-1][0]]==[]:
        q[now].pop()
        if q[now]==[]:
            break
    if dist[q[now][-1][0]]!=max:
        if len(q[now])!=1:
            q[now]=[q[now][-1]]+q[now][:-1]
    posi=q[now][-1]
    if dist[posi[0]]==max:
        dist[posi[0]]=now_d+posi[1]
    now_d=dist[posi[0]]
    q[now].pop()
    now=posi[0]
    posi=q[posi[0]][0]
for i in range(N):
    if dist[i]%2==0:
        print(0)
    else:
        print(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):
t=int(input())
m=0
while 1000*m<t:
    m=m+1
c=1000*m-t
print(t)

Fixed, accepted submission:
t=int(input())
m=0
while 1000*m<t:
    m=m+1
c=1000*m-t
print(c)
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 = str(input())
odd =[]

n = int(len(s)/2)

for i in range(n):
    odd.append(s[2*i])

print(''.join(odd))

Fixed, accepted submission:
s = str(input())
s = s[::2]
print(s)
Problem:
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.

Incorrect submission (verdict: Wrong Answer):

n,k = map(int,input().split())
x = [0]* (10**5)

for i in range(n):
    a,b = map(int,input().split())
    x[a-1] += b
#print(x)

count = 0
for i in range(n):
    count += x[i]
    if count >= k:
        print(i)
        break


Fixed, accepted submission:
N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = map(int, input().split())
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
s=input()
print("True") if s[:a].isdigit() and s[a:b]=='-' and s[b:].isdigit() else print("No")

Fixed, accepted submission:
a,b=map(int,input().split())
s=input()
if s[:a].isdigit() and s[a]=='-' and s[a+1:a+b+1].isdigit():
    print("Yes")
else:
    print("No")
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
#ABC060A
A,B,C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
#ABC060A
A,B,C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
r, g, b = map(int, input().split())
x = 10 * g + b
if x % 4 == 0:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
r, g, b = map(int, input().split())
x = 10 * g + b
if x % 4 == 0:
    print('YES')
else:
    print('NO')
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()
r = 0
for s in  S:
    if s == "o":
        r += 1
if r >= 8:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:
S = input()
r = 0
for s in S:
    if s == "x":
        r += 1
if r < 8:
    print("YES")
else:
    print("NO")
Problem:
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa.  In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white.  Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.

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

count = 0
check = S[0]

for i in S[1:]:
    if check != S:
        count+=1
        check = i
        
print(count)

Fixed, accepted submission:
S = input()
count = 0
check = S[0]

for i in S[1:]:
    if check != i:
        count+=1
        check = i
        
print(count)
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

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

def is_beutifull_str(char_str):
    for s in w:
        if w.count(s)%2 == 1:
            return 'NO'
    return 'YES'

print (is_beutifull_str(w))

Fixed, accepted submission:
w = input()

def is_beutifull_str(char_str):
    for s in w:
        if w.count(s)%2 == 1:
            return 'No'
    return 'Yes'

print (is_beutifull_str(w))
Problem:
We have N sticks with negligible thickness. The length of the i-th stick is A_i.  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Incorrect submission (verdict: Time Limit Exceeded):
N=int(input())
A=(int(i) for i in input().split())

C=[0 for i in range(1000000000)]

for i in A:
  C[i]+=1

print(C)

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

A.sort(reverse=True)

x=0
y=0
for i in range(N-1):
      if A[0]==A[1]:
          x=A[0]
          A.remove(x)
          A.remove(x)
          break
      else:
          A.remove(A[0])
if len(A)>=2:
    for i in range(len(A)-1):
        if A[0]==A[1]:
            y=A[0]
            break
        else:
            A.remove(A[0])

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

Incorrect submission (verdict: Wrong Answer):
L = []
for i in range(int(input())):
  L.append(input())
print(L)
for j in ['AC','WA','TLE','RE']:
  print(j,'x',L.count(j))

Fixed, accepted submission:
L = []
for i in range(int(input())):
  L.append(input())
for j in ['AC','WA','TLE','RE']:
  print(j,'x',L.count(j))
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()

out=[]
for c in list(s):
  if c=='0':
    out.append('0')
  elif c=='1':
    out.append('1')
  else:
    if len(out)>0:
      del out[-1]
print(out)

Fixed, accepted submission:
s=input()

out=[]
for c in list(s):
  if c=='0':
    out.append('0')
  elif c=='1':
    out.append('1')
  else:
    if len(out)>0:
      del out[-1]
print(''.join(out))
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
c = int(input())
j =  [0]*4
for i in range(c):
  i = input()
  if i == "AC":
    j[0] += 1
  elif i == "WA":
    j[1] += 1
  elif i == "TLE":
    j[2] += 1
  else:
    j[3] += 1
    
print("AC × "+ str(j[0]))
print("WA × "+ str(j[1]))
print("TLE × "+ str(j[2]))
print("RE × "+ str(j[3]))


Fixed, accepted submission:
c = int(input())
j =  [0]*4
for i in range(c):
  a = input()
  if a == "AC":
    j[0] += 1
  elif a == "WA":
    j[1] += 1
  elif a == "TLE":
    j[2] += 1
  else:
    j[3] += 1
    
print("AC x "+ str(j[0]))
print("WA x "+ str(j[1]))
print("TLE x "+ str(j[2]))
print("RE x "+ str(j[3]))
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):
import math
n = int(input())

v = [0]*(100000)

for x in range(101):
  for y in range(101):
    for z in range(101):
      v[x*x+y*y+z*z+x*y+y*z+z*x] += 1

for i in range(n):
  print(v[i+1])



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

v = [0]*(100000)

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      v[x*x+y*y+z*z+x*y+y*z+z*x] += 1

print('\n'.join(map(str,v[1:n+1])))
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):
s = input()
D = []
for i in range(10):
    D.append(s.count('i'))
a = max(D)
if a >= 3:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
s = input()
if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:
    print('Yes')
else:
    print('No')
Problem:
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.  The preliminary stage consists of several rounds, which will take place as follows:    * All the N contestants will participate in the first round.   * When X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:     * The organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.   For example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen).   When X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen.    * The preliminary stage ends when 9 or fewer contestants remain.  Ringo, the chief organizer, wants to hold as many rounds as possible. Find the maximum possible number of rounds in the preliminary stage.  Since the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \ldots, d_M and c_1, \ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \ldots, and the last c_M digits are all d_M.

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

dnum =0
dsum =0

for i in range(n):
  d,c=map(int,input().split())
  dnum += c
  dsum += d*c
  
ans = c-1 + dsum//9

print(ans)

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

dnum =0
dsum =0

for i in range(n):
  d,c=map(int,input().split())
  dnum += c
  dsum += d*c
  
ans = dnum-1 + (dsum-1)//9

print(ans)
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
s = input()
ans=0
for i in range(3):
    if s[i] == 1:
        ans += 1
print(ans)

Fixed, accepted submission:
s = input()
ans=0
for i in range(3):
    if s[i] == '1':
        ans += 1
print(ans)
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):
N = int(input())
print(24-N)


Fixed, accepted submission:
N = int(input())
print(48-N)
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
# 85 A
L = input()
L1 = L.replace("7","8")


print(L1)

Fixed, accepted submission:

s = input()
ss = s.replace("7","8",1)
print(ss)
Problem:
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).  The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
         
for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ''+ str(n)
        if not key in cards:
            print(key)


Fixed, accepted submission:
n = int(input())
cards = {}
for i in range(n):
         card = input()
         cards[card] = 1
         
for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)