TnT/CodeNet4Repair huggingface dataset:
Problem:
For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.

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

G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]

import heapq

def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
    
    while(len(q)):
        print(q)
        p=heapq.heappop(q)
        v=p[1]
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                
                heapq.heappush(q, (d[e[0]], e[0]))

import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
    
dijkstra(0)
for i in range(V):
    print(i, d[i])
    

    

Fixed, accepted submission:
V=int(input())
 
G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]
used=[False for i in range(V)]
 
import heapq
 
def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
     
    while(len(q)):
         
        p=heapq.heappop(q)
        v=p[1]
        used[v]=True
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if (not used[e[0]]) and d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                 
                heapq.heappush(q, (d[e[0]], e[0]))
 
import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
     
dijkstra(0)
for i, c in enumerate(d):
    print(i, d[i])
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

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

Fixed, accepted submission:
m = int(input())
print((24-m) + 24)
Problem:
Niwango-kun is an employee of Dwango Co., Ltd.   One day, he is asked to generate a thumbnail from a video a user submitted.   To generate a thumbnail, he needs to select a frame of the video according to the following procedure:    * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.   * Select t-th frame whose representation a_t is nearest to the average of all frame representations.   * If there are multiple such frames, select the frame with the smallest index.  Find the index t of the frame he should select to generate a thumbnail.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mu = sum(A) / N
diff = 1000
ans = 0
for a in A:
  if abs(a - mu) < diff:
    diff = abs(a - mu)
    ans = a

print(ans)

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
mu = sum(A) / N
diff = 1000
ans = 0
for i, a in enumerate(A):
  if abs(a - mu) < diff:
    diff = abs(a - mu)
    ans = i

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):
numbers_list = input().split()
count5 = numbers_list.count('5')
count7 = numbers_list.count('7')
if count5 == 2 and count7 == 1:
  print('YES')
else:
  print('NO')
print(numbers_list)


Fixed, accepted submission:
numbers_list = input().split()
count5 = numbers_list.count('5')
count7 = numbers_list.count('7')
if count5 == 2 and count7 == 1:
  print('YES')
else:
  print('NO')
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
A = int(input())
B = int(input())
C  =int(input())
X = int(input())
count = 0

for i in range(A + 1):
    total = i * 500
    print("i",i, total)
    if total == X:
        count += 1
        continue
    if total > X:
        break

    for j in range(B + 1):
        total = i * 500
        total += j * 100
        print("j" ,i , j,total)

        if total == X:
            count += 1

        if total > X:
            break

        for k in range(1,C + 1):
            total += 50
            print("k",i,j,k , total)
            if total == X:
                count += 1


            if total > X:
                break
print(count)




Fixed, accepted submission:
A = int(input())
B = int(input())
C  =int(input())
X = int(input())
count = 0

for i in range(A + 1):
    total = i * 500
    if total == X:
        count += 1
        continue
    if total > X:
        break

    for j in range(B + 1):
        total = i * 500
        total += j * 100

        if total == X:
            count += 1

        if total > X:
            break

        for k in range(1,C + 1):
            total += 50

            if total == X:
                count += 1


            if total > X:
                break
print(count)
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a, b, c = [int(i) for i in input().split()]

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

Fixed, accepted submission:
a, b, c = [int(i) for i in input().split()]

if a <= c and c <= b:
    print("Yes")
elif b <= c and c <= a:
    print("Yes")
else:
    print("No")
Problem:
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = 1
t = 1
for i in range(1, n+1):
  s *= i
for i in range(1, s+1):
  if s % i == 0:
    t += 1
print(t % (10 ** 9 + 7))

Fixed, accepted submission:
n = int(input())
s = 1
ans = 1
for i in range(1, n+1):
  s *= i
for i in range(2, n+1):
  k = 1
  while s % i == 0:
    s = s // i
    k += 1
  ans *= k
print(ans % (10 ** 9 + 7))
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
import math as m
N = int(input())
X = m.floor(m.sqrt(N))
print(X)


Fixed, accepted submission:
import math as m
N = int(input())
X = m.pow(m.floor(m.sqrt(N)),2)
print(int(X))
Problem:
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:  \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\]  where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.

Incorrect submission (verdict: Wrong Answer):
n, m, l = map(int, input().split())
a = []
b = []
for _ in range(n):
  a.append(list(map(int, input().split())))
for _ in range(m):
  b.append(list(map(int, input().split())))
b = list(zip(*b))
for i in range(n):
  for j in range(l):
    t = 0
    for k, l in zip(a[i], b[j]):
      t += k * l
    print(t, end = " ")
  print("")



Fixed, accepted submission:
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in a:
  c = []
  for j in zip(*b):
    c.append(sum([k * l for k, l in zip(i, j)]))
  print(*c)
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):
import sys

input = sys.stdin.readline
S = input()
print(S)
S = S.replace('\n' , '')
tmp = ""
division_count = 0
for s in S:
    if tmp == "":
        tmp = s
        continue
    if tmp == s:
        continue
    else:
        tmp = s
        division_count += 1
print(division_count)


Fixed, accepted submission:
import sys

input = sys.stdin.readline
S = input()
S = S.replace('\n' , '')
tmp = ""
division_count = 0
for s in S:
    if tmp == "":
        tmp = s
        continue
    if tmp == s:
        continue
    else:
        tmp = s
        division_count += 1
print(division_count)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0, a):
    for j in range(0,b):
        for k in range(0,c):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)
Problem:
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.  The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.  How many different PIN codes can he set this way?  Both the lucky number and the PIN code may begin with a 0.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
code = input()
f = 0
total = 0
for i in range(100,1000):
  s = str(i)
  idx = -1
  for dig in range(3):
    idx = code.find(s[dig], idx+1) 
    if idx == -1:
      break
  if idx != -1:
    total += 1
print(total)
        
      
  

Fixed, accepted submission:
n = int(input())
code = input()
f = 0
total = 0
for i in range(0,1000):
  s = str(i)
  if i< 10:
    s = '00' + s
  elif i < 100:
    s = '0' + s
  idx = -1
  for dig in range(3):
    idx = code.find(s[dig], idx+1) 
    if idx == -1:
      break
  if idx != -1:
    total += 1
print(total)
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=int(input())
count1=0
count2=0
count3=0
count4=0

for i in range(n):
  s=input()
  if(s=="AE"):
    count1+=1
  elif(s=="WA"):
    count2+=1
  elif(s=="TLE"):
    count3+=1
  elif(s=="RE"):
    count4+=1
print("AE x",count1)
print("WA x",count2)
print("TLE x",count3)
print("RE x",count4)

Fixed, accepted submission:
n=int(input())
count1=0
count2=0
count3=0
count4=0
 
for i in range(n):
  s=input()
  if(s=="AC"):
    count1+=1
  elif(s=="WA"):
    count2+=1
  elif(s=="TLE"):
    count3+=1
  elif(s=="RE"):
    count4+=1
print("AC x",count1)
print("WA x",count2)
print("TLE x",count3)
print("RE x",count4)
Problem:
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.

Incorrect submission (verdict: Wrong Answer):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    [n, s, k] = [str(readline().rstrip()) for _ in range(3)]
    print(s)
    s = list(s)
    strS = ""
    target = s[int(k) - 1]
    for i in range(int(n)):
        if s[i] == target:
            strS += s[i]
        else:
            strS += "*"
    print(strS)


if __name__ == '__main__':
    main()


Fixed, accepted submission:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    [n, s, k] = [str(readline().rstrip()) for _ in range(3)]
    s = list(s)
    strS = ""
    target = s[int(k) - 1]
    for i in range(int(n)):
        if s[i] == target:
            strS += s[i]
        else:
            strS += "*"
    print(strS)


if __name__ == '__main__':
    main()
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a = n//1.08
if int(a*1.08)==n:
  print(a)
else:
  print(":(")

Fixed, accepted submission:
import math
n=int(input())
a = n/1.08
b =math.ceil(a)
c=math.floor(a)
if math.floor(b*1.08)==n:
  print(b)
elif math.floor(c*1.08)==n:
  print(c)
else:
  print(":(")
Problem:
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.  Print the answer in degrees, but do not print units.

Incorrect submission (verdict: Wrong Answer):
print(int(input()*60))

Fixed, accepted submission:
print(180*(int(input())-2))
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):
import calendar

a,b = map(int,input().split())
_, lastday =calendar.monthrange(2018, a)
_, lastdayb = calendar.monthrange(2018,b)
print("Yes" if a == b else "No")

Fixed, accepted submission:
import calendar

a,b = map(int,input().split())
_, lastday =calendar.monthrange(2018, a)
_, lastdayb = calendar.monthrange(2018,b)
print("Yes" if lastday == lastdayb else "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):
# B - Varied
S = str(input())

if set(S) == len(S):
    print('yes')
else:
    print('no')

Fixed, accepted submission:
# B - Varied
S = str(input())

if len(set(S)) == len(S):
    print('yes')
else:
    print('no')
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):
A, B, C, D = input()
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            ans = A + i + B + j + C + k + D
            if eval(ans) == 7:
                break
print(ans + "=7")

Fixed, accepted submission:
A, B, C, D = input()
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            ans = A + i + B + j + C + k + D
            if eval(ans) == 7:
                print(ans + "=7")
                exit()
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
	if a<= sum(list(map(int,list(str(i))))) <=b:
		ans+=1
print(ans)


Fixed, accepted submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

req_500 = X//500
max_500 = min(req_500, A)

for i in range(0, max_500+1):
	X_sub500 = X - 500*i
	req_100 = X_sub500//100
	max_100 = min(req_100, B)
		
	for j in range(0, max_100+1):
		X_sub100 = X_sub500 - 100*j
		req_50 = X_sub100//50
		if req_50 <= C:
			count += 1

Fixed, accepted submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

req_500 = X//500
max_500 = min(req_500, A)

for i in range(0, max_500+1):
	X_sub500 = X - 500*i
	req_100 = X_sub500//100
	max_100 = min(req_100, B)
		
	for j in range(0, max_100+1):
		X_sub100 = X_sub500 - 100*j
		req_50 = X_sub100//50
		if req_50 <= C:
			count += 1

print(count)
Problem:
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:                 Counting-Sort(A, B, k) 1    for i = 0 to k 2        do C[i] = 0 3    for j = 1 to length[A] 4        do C[A[j]] = C[A[j]]+1 5    /* C[i] now contains the number of elements equal to i */ 6    for i = 1 to k 7    do C[i] = C[i] + C[i-1] 8    /* C[i] now contains the number of elements less than or equal to i */ 9    for j = length[A] downto 1 10       do B[C[A[j]]] = A[j] 11          C[A[j]] = C[A[j]]-1   Write a program which sorts elements of given array ascending order based on the counting sort.

Incorrect submission (verdict: Wrong Answer):
def counting_sort(lst,ans,max):
    cnt_lst = [0] * (max+1)
    for i in range(1,len(lst)):
        cnt_lst[lst[i]] += 1
    for j in range(1,max+1):
        cnt_lst[j] = cnt_lst[j] + cnt_lst[j-1]

    for k in range(len(lst)-1,0,-1):
        ans[cnt_lst[lst[k]]] = lst[k]
        cnt_lst[lst[k]] -= 1
    return ans

n = int(input())
n_lst = list(map(int,input().split()))
ans = [0] * len(n_lst)
ans = counting_sort(n_lst,ans,max(n_lst))
print(ans)


Fixed, accepted submission:
def counting_sort(lst,ans,max):
    cnt_lst = [0] * (max+1)
    for i in range(0,len(lst)):
        cnt_lst[lst[i]] += 1
    for j in range(1,max+1):
        cnt_lst[j] = cnt_lst[j] + cnt_lst[j-1]

    for k in range(len(lst)-1,-1,-1):
        ans[cnt_lst[lst[k]]-1] = lst[k]
        cnt_lst[lst[k]] -= 1
    return ans

n = int(input())
n_lst = list(map(int,input().split()))
ans = [0] * len(n_lst)
ans = map(str,counting_sort(n_lst,ans,max(n_lst)))
print(' '.join(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):
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0
#####################################

for i in range(0,n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
    tmp = A[i]
    A[i] = A[minj]
    A[minj] = tmp
    cnt += 1

#####################################
for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])
print (cnt)

Fixed, accepted submission:
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0
#####################################

for i in range(0,n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
    if(A[i] != A[minj]):
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        cnt += 1

#####################################
for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])
print (cnt)
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())

ans = 1000 - (n % 1000)

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

ans = (1000 - n%1000)%1000

print(ans)
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 ==0:
  print('possible')
  
else:
  print('impossible')

Fixed, accepted submission:
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 ==0:
  print('Possible')
  
else:
  print('Impossible')
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

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

Fixed, accepted submission:
a,b,c=map(int,input().split())
print(["No","Yes"][a<=c<=b])