TnT/CodeNet4Repair huggingface dataset:
Problem:
We held two competitions: Coding Contest and Robot Maneuver.  In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.  DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.

Incorrect submission (verdict: Wrong Answer):
X, Y = map(int,input().split())
sum = 0
def get_money(X, sum):
    if X == 1:
        sum += 300000
    elif X == 2:
        sum += 200000

    elif X == 3:
        sum += 100000

get_money(X, sum)
get_money(Y, sum)

if X == 1 and Y ==1:
    sum += 400000

print(sum)

Fixed, accepted submission:
X, Y = map(int,input().split())

def get_money(X):
    if X == 1:
        return 300000
    elif X == 2:
        return 200000
    elif X == 3:
        return 100000
    else:
        return 0

def double_money(X, Y):
    if X == 1 and Y == 1:
        return 400000
    else:
        return 0

sum = get_money(X) + get_money(Y) +double_money(X, Y)

print(sum)
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
s=list(input())

for i in range(2**(len(s)-1)):
    f =['']*(len(s)-1)
    siki=''
    for j in range(len(s)-1):
        if(i>>j & 1):
            f[j] = '+'
        else:
            f[j] = '-'
    for k in range(len(s)-1):
        siki += s[k] + f[k]
    siki += s[-1]
    if eval(siki)==7:
        print(siki)

Fixed, accepted submission:
s=list(input())

for i in range(2**(len(s)-1)):
    f =['']*(len(s)-1)
    siki=''
    for j in range(len(s)-1):
        if(i>>j & 1):
            f[j] = '+'
        else:
            f[j] = '-'
    for k in range(len(s)-1):
        siki += s[k] + f[k]
    siki += s[-1]
    if eval(siki)==7:
        siki += '=7'
        print(siki)
        break
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())

lst = [0] * (N+1)

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w%2 == 0:
#        print ('A')
        if lst[u] == 0 and lst [v] == 0:
            lst[u] = 1
            lst[v] = 1
        elif lst[u] != 0:
            lst[v] = lst[u]
        elif lst[v] != 0:
            lst[u] = lst[v]
#    print (lst)

#print (lst)
for j in range(1,N+1):
    print(lst[j])

Fixed, accepted submission:
N = int(input())
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline

lst = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    w = w%2
    lst[u].append([v, w])
    lst[v].append([u, w])
# print (lst)
ans = [-1] * (N + 1)
def dfs(x): 
    
    #     return ans[x]
    for i in lst[x]: 
        # print (i)
        if ans[i[0]] == -1: 
            if i[1] == 0: 
                ans[i[0]] = ans[x] 
                dfs(i[0])
            else: 
                ans[i[0]] = (ans[x] + 1) % 2
                dfs(i[0])
    return 

ans[1] = 0
dfs(1)
for i in ans[1:]:
    print (i)
Problem:
A priority queue is a data structure which maintains a set $S$ of elements, each of with an associated value (key), and supports the following operations:    * $insert(S, k)$: insert an element $k$ into the set $S$   * $extractMax(S)$: remove and return the element of $S$ with the largest key  Write a program which performs the $insert(S, k)$ and $extractMax(S)$ operations to a priority queue $S$. The priority queue manages a set of integers, which are also keys for the priority.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  9 13:21:18 2018
ALDS1-9c
@author: maezawa
"""
import math

def parent(node):
    return math.floor(node/2)

def left(node):
    return 2*node

def right(node):
    return 2*node+1

def max_heapify(a, i):
    l = left(i)
    r = right(i)
    if l <= h and a[l-1] > a[i-1]:
        largest = l
    else:
        largest = i
    if r <= h and a[r-1] > a[largest-1]:
        largest = r
        
    if largest != i:
        a[i-1], a[largest-1] = a[largest-1], a[i-1]
        max_heapify(a, largest)

def build_max_heap(a):
    for i in list(range(1,h//2+1))[::-1]:
        max_heapify(a, i)
        #print(a)

def insert(key):
    global h
    h += 1
    a[h-1] = -3*10**9
    heap_increase_key(a, h, key)
        
def heap_increase_key(a, i, key):
    if key < a[i-1]:
        print('error')
        return False
    a[i-1] = key
    while i > 1 and a[parent(i)] < a[i-1]:
        a[i-1], a[parent(i)]  = a[parent(i)], a[i-1]
        i = parent(i)
    
def heap_extract(a):
    global h
    if h < 1:
        print('error')
    maxh = a[0]
    a[0] = a[h-1]
    h -= 1
    max_heapify(a, 1)
    return maxh
        
a = [0]*2000001
h = 0

while True:
    s = input()
    if s == 'end':
        break
    if s == 'extract':
        print(heap_extract(a))
        continue
    opcode, operand = s.split()
    data = int(operand)
    if opcode == 'insert':
        insert(data)

for i in range(h):
    print(' {}'.format(a[i]),end = '')
print()
    


Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  9 13:21:18 2018
ALDS1-9c
@author: maezawa
"""
import heapq as hq
        
h = []

while True:
    s = input()
    if s == 'end':
        break
    if s == 'extract':
        print(-hq.heappop(h))
        continue
    opcode, operand = s.split()
    data = int(operand)
    if opcode == 'insert':
        hq.heappush(h, -data)
Problem:
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Incorrect submission (verdict: Wrong Answer):
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(alist)
    print(sum(alist))


Fixed, accepted submission:
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(sum(alist))
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)]

clrs = [-1]*(N+1)

for u, v, w in uvw:
    if clrs[u]!=-1 and clrs[v]==-1:
        if w%2==0:clrs[v]=clrs[u]
        else:clrs[v]=(clrs[u]+1)%2
    elif clrs[u]==-1 and clrs[v]!=-1:
        if w%2==0:clrs[u]=clrs[v]
        else:clrs[u]=(clrs[v]+1)%2
    else:
        if w%2==0:
            clrs[u]=1
            clrs[v]=1
        else:
          clrs[u]=0
          clrs[v]=1
print(*clrs[1:N+1], sep='\n')

Fixed, accepted submission:
from collections import Counter, deque

N = int(input())

uvw = [list(map(int, input().split())) for _ in range(N-1)]

udict ={}
uvdict = {}
lst = []
ans = [-1]*(N+1)
for u, v, w in uvw:
    if u in udict:udict[u].append(v)
    else:udict[u] =[v]
    if v in udict:udict[v].append(u)
    else:udict[v] =[u]
    lst.append(u)
    lst.append(v)
    uvdict[(u,v)] = w
cnt = Counter(lst)

cnt_max = cnt.most_common()[0][0]
nxt = deque()
nxt.append(cnt_max)
passed = [0]*(N+1)

d = [0]*(N+1)

while nxt!=deque([]):
    l1 = nxt.popleft()
    for l2 in udict[l1]:
        if passed[l2]==1:continue
        d[l2] = d[l1] + uvdict[min(l1, l2), max(l1, l2)]
        
        nxt.append(l2)
    passed[l1]=1
for i in d[1:]:
    print(i%2)
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):
#coding:UTF-8
def BS(N,A):
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if int(A[j][1:])<int(A[j-1][1:]):
                swap=A[j]
                A[j]=A[j-1]
                A[j-1]=swap
    return A

def SS(N,A):
    for i in range(N):
        minj=i
        for j in range(i,N):
            if int(A[j][1:]) < int(A[minj][1:]):
                minj=j
        
        swap=A[i]
        A[i]=A[minj]
        A[minj]=swap
    return A

def Stable(A1,A2):
    ans="Stable"
    for i in range(len(A1)):
        if A1[i][1:]==A2[i][1:] and A1[i][:1]!=A2[i][:1]:
            ans="Not stable"
    return ans

def SS2(N,A,B):
    print(A,B)
    A1=BS(N,A)
    print(" ".join(A1))
    print("Stable")
    A2=SS(N,B)
    print(" ".join(A2))
    print(Stable(A1,A2))

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    B=a.split(" ")
    SS2(N,A,B)

Fixed, accepted submission:
#coding:UTF-8
def SS(N,A):
    count=0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j]<A[minj]:
                minj=j
        if i!=minj:
            count+=1
            swap=A[i]
            A[i]=A[minj]
            A[minj]=swap
    for i in range(len(A)):
        A[i]=str(A[i])
    print(" ".join(A))
    print(count)

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    for i in range(len(A)):
        A[i]=int(A[i])
    SS(N,A)
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())
if k <= -(-n // 2):
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
n, k = map(int, input().split())
if k <= -(-n // 2):
    print('YES')
else:
    print('NO')
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
def test(x):
    return x**2

Fixed, accepted submission:
import sys

d = int(sys.stdin.readline().rstrip())
print(d**3)
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
ai = [int(x) for x in input().split()]
min = ai[0]
max = ai[0]
total = 0
for x in ai:
    total += x
    if x < min:
        min = x
    if x > max:
        max = x



Fixed, accepted submission:
n = int(input())
ai = [int(x) for x in input().split()]
min = ai[0]
max = ai[0]
total = 0
for x in ai:
    total += x
    if x < min:
        min = x
    if x > max:
        max = x
print(min, max, total)
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):
from typing import List

def step(n: int, a: List[int])-> int:
  result = 0
  dai = 0
  for i in range(1,n):
    sub = a[i-1] + dai - a[i]
    print(sub)
    if sub > 0:
      dai = sub      
      result += sub
      continue
    dai = 0
  return result

if __name__ == "__main__":
  n = int(input())
  a = list(map(int, input().split()))
  print(step(n, a))

Fixed, accepted submission:
from typing import List

def step(n: int, a: List[int])-> int:
  result = 0
  dai = 0
  for i in range(1,n):
    sub = a[i-1] + dai - a[i]
    if sub > 0:
      dai = sub      
      result += sub
      continue
    dai = 0
  return result

if __name__ == "__main__":
  n = int(input())
  a = list(map(int, input().split()))
  print(step(n, a))
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()
T = ''
words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(words)):
    words[i] = words[i][::-1]
for i in S[::-1]:
    T += i
    for q in words:
        if T == q:
            T = ''
if T == '':
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
S = input()
L = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(L)):
    L[i] = L[i][::-1]
S = S[::-1]
T = ''
for s in S:
    T += s
    for i in L:
        if T == i:
            T = ''
if T == '':
    print('YES')
else:
    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):
n = input()

if n[0] == n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
n = input()

if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')
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):
value = int(input().strip())

exc = value % 1000

print(exc)


Fixed, accepted submission:
value = int(input().strip())

exc = value % 1000

print(1000-exc if exc > 0 else 0)
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())
ans = list(set(range(A, A+K)) | set(range(B-K, B)))
ans.sort()
for i in ans:
	if A <= i <= B:
		print(i)

Fixed, accepted submission:
A, B, K = map(int, input().split())
ans = list(set(range(A, A+K)) | set(range(B-K+1, B+1)))
ans.sort()
for i in ans:
	if A <= i <= B:
		print(i)
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())

print("YES" if (100*r+10*g+b%4)==0 else "NO")

Fixed, accepted submission:
r,g,b=map(int,input().split())

print("YES" if (100*r+10*g+b)%4==0 else "NO")
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):
words = input()
l = len(words)
output = words[0] + str(l-2) + words[l-1]
print(output)


Fixed, accepted submission:
n, m = input().split()
n = int(n)
m = int(m)
output = (n-1)*(m-1)

print(output)
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

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

ans=0

for i in range(N):
  l,r=map(int,input().split())
  ans+=l-r+1

print(ans)

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

ans=0

for i in range(N):
  l,r=map(int,input().split())
  #print(l,r)
  ans+=r-l+1

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):
def main():
    if input() == '5 7 5': print('YES')
    else: print('NO')

if __name__ == '__main__':
    main()

Fixed, accepted submission:
def main():
    if sorted(input().split()) == ['5','5','7']: print('YES')
    else: print('NO')

if __name__ == '__main__':
    main()
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
d = int(a//b)
r = a %b
f = a // b
print("%d %d %d" % (d, r, f))

Fixed, accepted submission:
a, b = map(int, input().split())
d = int(a/b)
r = a %b
f = a / b
print("%d %d %.5f" % (d, r, f))
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=[input() for i in range(H)]
R=[[] for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      R[i].append('#')
    else:
      cnt=0
      for k in range(max(0,i-1),min(H,i+2)):
        for h in range(max(0,j-1),min(W,j+2)):
          if S[k][h]=='#':
            cnt+=1
      R[i].append(cnt)

for i in range(H):
  print(*R[i])

Fixed, accepted submission:
H,W=map(int,input().split())
 
S=[input() for i in range(H)]
R=['' for i in range(H)]

for i in range(H):
  for j in range(W):
    sum=0
    if i!=0:
      sum+=S[i-1][max(0,j-1):min(W,j+2)].count('#')
    sum+=S[i][max(0,j-1):min(W,j+2)].count('#')
    if i!=H-1:
      sum+=S[i+1][max(0,j-1):min(W,j+2)].count('#') 
    if S[i][j]=='.':
      R[i]+=str(sum)
    else:      
      R[i]+='#'
    
print(*R,sep='\n')
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
ln_list = list(map(int, input().split()))
print(ln_list)
l = []
for list in range(ln_list[0]):
  l.append(input())
l.sort()
a = ''.join(l)
print(a)

Fixed, accepted submission:
ln_list = list(map(int, input().split()))
l = []
for list in range(ln_list[0]):
  l.append(input())
l.sort()
a = ''.join(l)
print(a)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

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

numbers = list(map(int, input().split()))

count = 0
while(True):
	if sum(list(map(lambda x: x % 2, numbers))) == 0:
		numbers = list(map(lambda x: x / 2, numbers))
		count += 1
	else:
		break
print(count)

Fixed, accepted submission:
# -*- coding: utf-8 -*-
input()
numbers = list(map(int, input().split()))
 
count = 0
while(True):
	if sum(list(map(lambda x: x % 2, numbers))) == 0:
		numbers = list(map(lambda x: x / 2, numbers))
		count += 1
	else:
		break
print(count)
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):
N = input()
L = list(N)
counter = 0
for i in range(len(L)) :
    l = int(L[i])
    counter += l
if int(N) % counter == 0 :
    print("Yes")
else :
    print("No")
    
print(counter)



Fixed, accepted submission:
N = input()
L = list(N)
counter = 0
for i in range(len(L)) :
    l = int(L[i])
    counter += l
if int(N) % counter == 0 :
    print("Yes")
else :
    print("No")