TnT/CodeNet4Repair huggingface dataset:
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
N, M = map(int,input().split())
graph = [[] for n in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)






q = [1]

ans = ['No' for n in range(N+1)]
ans[1] = 1 #ans[1]
while q: 
    
    now = q.pop(0)
    for edge in graph[now]:
        if ans[edge] != 'No':
            continue
        ans[edge] = now
        q.append(edge)

if not 'No' in ans:
    print('Yes')
    for n in range(2,N+1):
        print(ans[n])
else:
    print('No')





Fixed, accepted submission:
N, M = map(int, input().split())
graph = [[] for n in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)






q = [1]


ans = ['No' for n in range(N + 1)]
ans[0] = 1  
ans[1] = 1  

while q:  
    now = q.pop(0) 
    for edge in graph[now]:
        if ans[edge] != 'No': 
            continue
        ans[edge] = now
        q.append(edge)

if not 'No' in ans:
    print('Yes')
    for n in range(2, N + 1):
        print(ans[n])
else:
    print('No')
Problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:    * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.  Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

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


A, B, K = map(int, input().split())
print(A, B, K)

for i in range(K):
    if i % 2 == 0:
        
        if A % 2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        
        if B % 2 != 0:
            B -= 1
        B //= 2
        A += B


print("{} {}".format(A, B))


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


A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        
        if A % 2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        
        if B % 2 != 0:
            B -= 1
        B //= 2
        A += B


print("{} {}".format(A, B))
Problem:
Write a program which reads three integers, and prints them in ascending order.

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

#a,b,c=[int(x) for x in input().split()]

a,b,c=[int(x) for x in input().split()]

numlist = [a,b,c]

print(numlist.sort())


Fixed, accepted submission:


print(*sorted(map(int, input().split())))
Problem:
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode:                 BubbleSort(A) 1 for i = 0 to A.length-1 2     for j = A.length-1 downto i+1 3         if A[j] < A[j-1] 4             swap A[j] and A[j-1]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 4 of the pseudocode.

Incorrect submission (verdict: Wrong Answer):
def bubbleSort(A, N): 
    print(A)
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)


Fixed, accepted submission:
def bubbleSort(A, N): 
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(" ".join(map(str,A)))
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)
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())
A = [input() for _ in range(H)]

result = []
for a in A:
  result.append('*' + a +'*')
waku = '*' * (W+2)
result.insert(0,waku)
result.insert(len(A)+1,waku)
for r in result:
  print(r)

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

result = ["#"*(W+2)]
for _ in range(H):
  c = input()
  result.append("#"+c+"#")
result.append("#"*(W+2))
print("\n".join(result))
Problem:
We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row.  The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise.  Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel.  Solve this problem for each of the T test cases given.

Incorrect submission (verdict: Wrong Answer):


from heapq import heappop, heappush
import sys
input = sys.stdin.readline

def resolve():
    T = int(input())
    for _ in range(T):
        N = int(input())
        ans = 0
        camels0 = [[] for _ in range (n)]
        camels1 = [[] for _ in range (n)]
        for _ in range(N):
            K,L,R = map(int, input().split())
            if L>R:
                camels0[K-1].append(L-R)
            elif L<R and K<N:
                camels1[N-K-1].append(R-L)
            ans += min(L,R)
        
        H = []
        for i in range(N):
            for j in camels0[i]:
                heappush(H,j)
            while len(H) > i+1:
                heappop(H)
        ans += sum(H)
        H = []
        for i in range(N):
            for j in camels1[i]:
                heappush(H,j)
            while len(H) > i+1:
                heappop(H)
        ans += sum(H)
        print(ans)

Fixed, accepted submission:


from heapq import heappop, heappush
import sys
input = sys.stdin.readline

def resolve():
    T = int(input())
    for _ in range(T):
        N = int(input())
        ans = 0
        camels0 = [[] for _ in range (N)]
        camels1 = [[] for _ in range (N)]
        for _ in range(N):
            K,L,R = map(int, input().split())
            if L>R:
                camels0[K-1].append(L-R)
            elif L<R and K<N:
                camels1[N-K-1].append(R-L)
            ans += min(L,R)
        
        H = []
        for i in range(N):
            for j in camels0[i]:
                heappush(H,j)
            while len(H) > i+1:
                heappop(H)
        ans += sum(H)
        H = []
        for i in range(N):
            for j in camels1[i]:
                heappush(H,j)
            while len(H) > i+1:
                heappop(H)
        ans += sum(H)
        print(ans)
resolve()
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):
N=input()

c0=N.count("AC")
c1=N.count("WA")
c2=N.count("TLE")
c3=N.count("RE")

print("AC x "+str(c0))
print("WA x "+str(c1))
print("TLE x "+str(c2))
print("RE x "+str(c3))

Fixed, accepted submission:
N=int(input())
inp=[]

for i in range(N):
    inp.append((input()))

c0=inp.count("AC")
c1=inp.count("WA")
c2=inp.count("TLE")
c3=inp.count("RE")

print("AC x "+str(c0))
print("WA x "+str(c1))
print("TLE x "+str(c2))
print("RE x "+str(c3))
Problem:
Joisino the magical girl has decided to turn every single digit that exists on this world into 1.  Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points).  She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive).  You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows:    * If A_{i,j}≠-1, the square contains a digit A_{i,j}.   * If A_{i,j}=-1, the square does not contain a digit.  Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.

Incorrect submission (verdict: Wrong Answer):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
from heapq import heappush, heappop
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


H, W = na()
c = [na() for _ in range(10)]
A = [na() for _ in range(H)]
adj = [[] for _ in range(10)]

c = np.array(c)
d = shortest_path(c, indices=1)
#print(d)
ans = 0
for y in range(H):
    for x in range(W):
        if A[y][x] != -1:
            #print(ans)
            ans += d[A[y][x]]
print(int(ans))



Fixed, accepted submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
from heapq import heappush, heappop
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


H, W = na()
c = [na() for _ in range(10)]
A = [na() for _ in range(H)]
adj = [[] for _ in range(10)]

c = np.array(c)
d = shortest_path(c)
ans = 0
for y in range(H):
    for x in range(W):
        if A[y][x] != -1:
            #print(ans)
            ans += d[A[y][x]][1]
print(int(ans))
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):
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if  n - k <0:
  print(int(n * x))
else:
  print(int((k * y) + (n - k) * y))

Fixed, accepted submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if  n - k <0:
  print(int(n * x))
else:
  print(int((k * x) + (n - k) * y))
Problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.  

Incorrect submission (verdict: Wrong Answer):
x,y = map(int,input().split())
if x ==2 and y == 2:
    print('Yes')
elif x % 2 == y % 2 and x >=4 and y >= 4:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
x,y = map(int,input().split())
a_group = [1,3,5,7,8,10,12]
b_group = [4,6,9,11]
c_group = [2]

if x in a_group and y in a_group:
    print('Yes')
elif x in b_group and y in b_group:
    print('Yes')
elif x in c_group and y in c_group:
    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):
N = int(input())

print(N-(N//1000)*1000)

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

if(N >= 1000):
    if(N%1000 != 0):
        print((N//1000+1)*1000-N)
    else:
        print(0)
else:
    print(1000-N)
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):
input_str = ''.join(list(map(str, input())))
if input_str == '755' or input_str == '575' or input_str == '557':
    print('YES')
else:
    print('NO')

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




if input_str == [7, 5, 5] or input_str == [5, 7, 5] or input_str == [5, 5, 7]:
    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):
m=int(input())
for i in range(0, 10):
  if i*1000 <= m < (i+1)*1000:
    print(m-i*1000)

Fixed, accepted submission:
m=int(input())
for i in range(0, 11):
  if i*1000 < m <= (i+1)*1000:
    m=(i+1)*1000 - m
print(m)
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):
payment = int(input())
bucks = 1000
change = payment%bucks
print(change)

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

bucks = 1000

if payment%bucks == 0:
  change = 0
else:
  receive = payment//bucks + 1
  change = receive*bucks - payment

print(change)
Problem:
Snuke has N strings. The i-th string is s_i.  Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l = []
cnt = 0
te = [0,0,0]
for i in range(n):
    l.append(input())
for i in l:
    if i[0] == "B" and i[-1] == "A":
        te[0] += 1
    elif i[0] == "B":
        te[1] += 1
    elif i[-1] == "A":
        te[2] += 1
    for j in range(len(i)-1):
        if i[j] == "A" and i[j+1] == "B":
            cnt += 1
if te[0] != 0:
    te[0] -= 1
if te[1]>0:
    te[0] += 1
    te[1] -= 1
if te[2]>0:
    te[0] += 1
    te[2] -= 1
print(cnt+te[0]+min(te[1],te[2]))

Fixed, accepted submission:
n = int(input())
l = []
cnt = 0
te = [0,0,0]
for i in range(n):
    l.append(input())
for i in l:
    if i[0] == "B" and i[-1] == "A":
        te[0] += 1
    elif i[0] == "B":
        te[1] += 1
    elif i[-1] == "A":
        te[2] += 1
    for j in range(len(i)-1):
        if i[j] == "A" and i[j+1] == "B":
            cnt += 1
if te[0] != 0:
    te[0] -= 1
    if te[1]>0:
        te[0] += 1
        te[1] -= 1
    if te[2]>0:
        te[0] += 1
        te[2] -= 1
print(cnt+te[0]+min(te[1],te[2]))
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 = input()
letters = []
ans = 'no'
for i in s:
  if i in letters:
    ans = 'yes'
    break
  else:
    letters.append(i)
print(ans)

Fixed, accepted submission:
s = input()
letters = []
ans = 'yes'
for i in s:
  if i in letters:
    ans = 'no'
    break
  else:
    letters.append(i)
print(ans)
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):
payment = int(input())

print(payment%1000)


Fixed, accepted submission:
payment = int(input())
num = int(payment//1000)
if payment%1000 != 0:
    num += 1
print((num*1000)-payment)
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
A, B, C, X, Y = map(int,input().split())

m = 10^9
for i in range(X):
  for j in range(Y):
    m = min(m,A*i+B*j+C*((X+Y)-(i+j)))
    
print(m)

Fixed, accepted submission:
def solve(a,b,c,x,y):
  l = []
  for i in range(10**6):
    s = a*max(x-i,0)+b*max(y-i,0)+c*i*2
    l.append(s)
  return min(l)

        

A,B,C,X,Y = map(int,input().split())
print(solve(A,B,C,X,Y))
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):

N = int(input())
K = int(input())
X = int(input())
Y = int(input())


account = 0
cnt = 1
for cnt in range(1,K + 1,1):
  account = account + X
  
for cnt in range(K + 1,N,1):
  account = account + Y
  
print(account)

Fixed, accepted submission:

N = int(input())
K = int(input())
X = int(input())
Y = int(input())


if N <= K:
  account = N * X
else:
  account = (K * X) + (max(N - K,0) * Y) 
  
print(account)
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

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

print(len(set(x)))

Fixed, accepted submission:
abc = list(input().split())

print(len(set(abc)))
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a,b,h = map(int,open(0).read().split())
print((a+b)+h/2)

Fixed, accepted submission:
a,b,h = map(int,open(0).read().split())
print(int((a+b)*h/2))
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):
plus = lambda a,b:a+b
minus = lambda a,b:a-b

bit = 0

nums = [int(c) for c in input()]

for bit in range(8):
  op_lst = [(plus if bit >> i & 1 else minus) for i in [2,1,0]]
  temp = nums[0]
  for i in range(len(op_lst)):
    temp = op_lst[i](temp,nums[i+1])
  if temp == 7:
    break

op_strings = {plus:"+",minus:"-"}

s = str(nums[0]) + op_strings[op_lst[0]] + str(nums[1]) + op_strings[op_lst[1]] + str(nums[2]) + op_strings[op_lst[2]] + str(nums[3])

print(s)

Fixed, accepted submission:
plus = lambda a,b:a+b
minus = lambda a,b:a-b

bit = 0

nums = [int(c) for c in input()]

for bit in range(8):
  op_lst = [(plus if bit >> i & 1 else minus) for i in [2,1,0]]
  temp = nums[0]
  for i in range(len(op_lst)):
    temp = op_lst[i](temp,nums[i+1])
  if temp == 7:
    break

op_strings = {plus:"+",minus:"-"}

s = str(nums[0]) + op_strings[op_lst[0]] + str(nums[1]) + op_strings[op_lst[1]] + str(nums[2]) + op_strings[op_lst[2]] + str(nums[3])

print(s+"=7")
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp


def insertion_sort(target_list, n_list):
    
    for focus_index in range(1, n_list):
        print(*target_list)
        target = target_list[focus_index]
        if target < target_list[focus_index - 1]:
            compare_index = focus_index

            while compare_index > 0 and target_list[compare_index - 1] > target:
                target_list[compare_index] = target_list[compare_index - 1]
                compare_index -= 1;

            target_list[compare_index] = target
        
    return target_list

def main():
    n_list = int(input())
    target_list = [int(a) for a in input().split()]
    insertion_sort(target_list, n_list)
if __name__ == "__main__":
    main()

Fixed, accepted submission:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp


def insertion_sort(target_list, n_list):
    
    for focus_index in range(1, n_list):
        print(*target_list)
        target = target_list[focus_index]
        if target < target_list[focus_index - 1]:
            compare_index = focus_index

            while compare_index > 0 and target_list[compare_index - 1] > target:
                target_list[compare_index] = target_list[compare_index - 1]
                compare_index -= 1;

            target_list[compare_index] = target
    
    return target_list

def main():
    n_list = int(input())
    target_list = [int(a) for a in input().split()]
    print(*insertion_sort(target_list, n_list))
if __name__ == "__main__":
    main()