TnT/CodeNet4Repair huggingface dataset:
Problem:
Find the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph G = (V, E).

Incorrect submission (verdict: Wrong Answer):
# Sliding Minimum Elements
INF = 2**31 - 1
[n, l] = list(map(int, input().split()))
data = list(map(int, input().split()))


def initRMQ(tree):
    global n
    size = 1
    while size < l:
        size *= 2
    i = 1
    while i <= 2*size - 1 - 1:
        tree.append(INF)
        i += 1
    n = size
    return tree

def update(k, a, temp):
    k += n - 1
    temp[k:k+l] = a
    for i in range(k, k+l, 2):
        while i > 0:
            i = int((i - 1)/2)
            temp[i] = min(temp[i*2 + 1], temp[i*2 + 2])


index = 0
array = initRMQ([INF])
while (len(data) - index - l) >= 0:
    #temp = list(array)
    #update(0, data[index:index+l], temp)
    temp = data[index:index+l]
    temp.sort()
    index += 1
    if (len(data) - index - l) < 0:
        print(temp[0])
    else:
        print(temp[0], "", end="")


Fixed, accepted submission:

p = []
rank = []
edge = []
cost = 0

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)

def findSet(x):
    global p
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]

def link(x, y):
    global p, rank
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1

def union(x, y):
    link(findSet(x), findSet(y))    

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   

[v, e] = list(map(int, input().split()))
for i in range(v):
    makeSet(i)

for i in range(e):
    [s, t, w] = list(map(int, input().split()))
    edge.append([w, s, t])

edge.sort()

while v > 1:
    min = edge.pop(0)
    if not same(min[1], min[2]):
        union(min[1], min[2])
        cost += min[0]
        v -= 1

print(cost)
Problem:
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
n = int(input().strip())
ab = [list(map(int, input().strip().split(" "))) for _ in range(n)]
cd = [list(map(int, input().strip().split(" "))) for _ in range(n)]
ab = sorted(ab, key=lambda x: x[1])
ab = sorted(ab, key=lambda x: x[0])
cd = sorted(cd, key=lambda x: x[1])
cd = sorted(cd, key=lambda x: x[0])
mat = [[0 for _ in range(n)] for _ in range(n)]
for i, _ab in enumerate(ab):
    for j, _cd in enumerate(cd):
        if _ab[0] < _cd[0] and _ab[1] < _cd[1]:
            mat[i][j] = 1
mat = sorted(mat, key=lambda x: sum(x))
mat = np.array(mat)
print(mat)
ind = set([])
for _mat in mat:
    iii = np.where(_mat > 0)[0]
    for _i in iii:
        if _i not in ind:
            ind.add(_i)
print(len(ind))

Fixed, accepted submission:
def solve(string):
    n, *abcd = map(int, string.split())
    abcd = [(ac, bd) for ac, bd in zip(abcd[::2], abcd[1::2])]
    ab = abcd[:n]

    candidate = []
    ans = 0
    ps = sorted(abcd, key=lambda x: x[0])
    for p in ps:
        if p in ab:
            candidate.append(p)
            candidate = sorted(candidate, key=lambda x: x[1], reverse=True)
        else:
            for i, _p in enumerate(candidate):
                if _p[1] < p[1]:
                    ans += 1
                    candidate.pop(i)
                    break
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(2 * n)])))
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
m,d=map(int,input().split())

ans=0
if d<10:
    print(0)
else:
    for i in range(10,d+1):
        for j in range(1,m+1):
            if (i%10)*(i//10)==j:
                ans+=1
    print(ans)

Fixed, accepted submission:
m,d=map(int,input().split())

ans=0
if d<10:
    print(0)
else:
    for i in range(10,d+1):
        for j in range(1,m+1):
            if (i%10)*(i//10)==j and i%10>=2 and (i//10)>1:
                ans+=1
    print(ans)
Problem:
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.  We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.      Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):      In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.  Your task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.  You may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10\.

Incorrect submission (verdict: Wrong Answer):
d = [[0] * 10 for i in range(10)]

def b(x, y):
    for i in range(x - 2, x + 3):
        a = 3 - abs(x - i)
        for a in range(y - a + 1, y + a):
            if 0 <= i < 10 and 0 <= a < 10:
                d[a][i] += 1


def m(x, y):
    for i in range(x - 1, x + 2):
        for j in range(y - 1, y + 2):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1


def s(x, y):
    r = (1, 0)
    for i in range(x - 1, x + 2):
        a = abs(x - i)
        for j in range(y - r[a], y + r[a] + 1):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1

while 1:
    try:
        f = (None, s, m, b)
        x, y, size = list(map(int, input().split(',')))
        f[size](x, y)

    except:
        break


r1 = r2 = 0
for i in range(10):
    for j in range(10):
        r1 += 1 if d[i][j] == 0 else 0
        r2 = max(r2, d[i][j])

print(r1, r2)

Fixed, accepted submission:
d = [[0] * 10 for i in range(10)]

def b(x, y):
    for i in range(x - 2, x + 3):
        a = 3 - abs(x - i)
        for a in range(y - a + 1, y + a):
            if 0 <= i < 10 and 0 <= a < 10:
                d[a][i] += 1


def m(x, y):
    for i in range(x - 1, x + 2):
        for j in range(y - 1, y + 2):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1


def s(x, y):
    r = (1, 0)
    for i in range(x - 1, x + 2):
        a = abs(x - i)
        for j in range(y - r[a], y + r[a] + 1):
            if 0 <= i < 10 and 0 <= j < 10:
                d[j][i] += 1

while 1:
    try:
        f = (None, s, m, b)
        x, y, size = list(map(int, input().split(',')))
        f[size](x, y)
    except:
        break


r1 = r2 = 0
for i in range(10):
    for j in range(10):
        r1 += 1 if d[i][j] == 0 else 0
        r2 = max(r2, d[i][j])

print(r1)
print(r2)
Problem:
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?

Incorrect submission (verdict: Wrong Answer):
N, A = [int(_) for _ in input().split()]
X = [int(_) - A for _ in input().split()]
X_plus = [_ for _ in X if _ > 0]
X_minus = [-_ for _ in X if _ < 0]
l_plus = len(X_plus)
l_minus = len(X_minus)
l_zero = len(X) - l_plus - l_minus
s_plus = sum(X_plus)
s_minus = sum(X_minus)
dp_plus = [0] * (l_plus + 1)
dp_minus = [0] * (l_minus + 1)
for i in range(l_plus):
    dp_plus_old = dp_plus.copy()
    for j in range(l_plus + 1 - X_plus[i]):
        dp_plus[j + X_plus[i]] += dp_plus_old[j]
for i in range(l_minus):
    dp_minus_old = dp_minus.copy()
    for j in range(l_minus + 1 - X_minus[i]):
        dp_minus[j + X_minus[i]] += dp_minus_old[j]
ans = 2 ** l_zero - 1
for j in range(min(l_plus, l_minus) + 1):
    ans += dp_plus[j] * dp_minus[j]
print(ans)


Fixed, accepted submission:
import collections
N, A = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]


def calc(W):
    
    M = len(W)
    dp = [collections.defaultdict(int) for _ in range(M + 1)]
    dp[0][0] = 1
    for i, w in enumerate(W):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                dp[j + 1][k + w] += v
    return dp


dpx = calc(X)
print(sum(dpx[i][i * A] for i in range(1, N + 1)))
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a + b < 9:
  print(a + b)
else:
  print('error')
 


Fixed, accepted submission:
a, b = map(int, input().split())
if a + b < 10:
  print(int(a + b))
else:
  print('error')
Problem:
Snuke built an online judge to hold a programming contest.  When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)  Determine whether the judge can return the string `AC` as the verdict to a program.

Incorrect submission (verdict: Wrong Answer):

def main():
    s = input()
    print("YES" if "AC" in s else "NO")


if __name__ == "__main__":
    main()

Fixed, accepted submission:

def main():
    s = input()
    print("Yes" if "AC" in s else "No")


if __name__ == "__main__":
    main()
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())

if N%1000 ==0:
    print(0)
else:
    print(N%1000)

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

if N%1000 == 0:
    print(0)
else:
    print(1000 - N%1000)
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())

l = [0]*4
w = ["AC","WA","TLE","RE"]

for i in range(n):
    s = input()
    if s == "AC":
        l[0] += 1
    elif s == "WA":
        l[1] += 1
    elif s == "TLE":
        l[2] += 1
    else:
        l[3] +=1
        
for i in range(4):
    print(w[i] + " × " + str(l[i]))
    

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

l = [0]*4
w = ["AC","WA","TLE","RE"]

for i in range(n):
    s = input()
    if s == "AC":
        l[0] += 1
    elif s == "WA":
        l[1] += 1
    elif s == "TLE":
        l[2] += 1
    else:
        l[3] +=1
        
for i in range(4):
    print(w[i] + " x " + str(l[i]))
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()

if S.count('o') >= 8:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
S = input()
r = 15 - len(S)
if S.count('o') + r >= 8:
    print('YES')
else:
    print('NO')
Problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:    * The graph is simple and connected.   * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.  It can be proved that at least one such graph exists under the constraints of this problem.

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

if N % 2 == 0:
    S = 1 + N
else:
    S = N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i+j == S:
            continue
        print(i, j)


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

if N % 2 == 0:
    S = 1 + N
else:
    S = N
ans = []
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i+j == S:
            continue
        ans.append([i, j])
print(len(ans))
for p in ans:
    print(p[0], p[1])
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a < b:
    print(a)

else:
    print(a-1)

Fixed, accepted submission:
a, b = map(int, input().split())
if a <= b:
    print(a)

else:
    print(a-1)
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
print(A)
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

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

D = sorted([A,B,C])

count = int((D[2] - D[0])/2) + int((D[2] - D[0])/2)
if (D[2] - D[0])%2 + (D[2] - D[0])%2 == 2:
    count += 1
else:
    count += 2

print(count)

Fixed, accepted submission:
A, B, C = map(int, input().split())

D = sorted([A,B,C])

count = int((D[2] - D[0])/2) + int((D[2] - D[1])/2)
E = (D[2] - D[0])%2 + (D[2] - D[1])%2

if E == 2:
    count += 1
elif E == 1:
    count += 2

print(count)
Problem:
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.  For example, if K = 3, print `ACLACLACL`.

Incorrect submission (verdict: Wrong Answer):
K=int(input())
K+=1
o=''
a='ALC'
for i in range(1,K):
  o=o+a
print(o)

Fixed, accepted submission:
k=int(input())
k+=1
o=''
a='ACL'
if k==1:
  print('')
  exit()
else:
  for i in range(1,k):
  	o=o+a
print(o)
Problem:
In this problem, we use the 24-hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?

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

trade = T.replace('?','D')
print(trade)


Fixed, accepted submission:
import datetime


H1,M1,H2,M2,K = map(int,input().split())

wakeup = datetime.datetime(2020,5,30,H1,M1,0)
sleep = datetime.datetime(2020,5,30,H2,M2,0)

active = sleep - wakeup
delta = int((active.seconds)/60)

ans = delta - K
print(ans)
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):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    abl=b-a+1
    ablist=[i for i in range(a,b+1)]
    #print(ablist)
    ansa=ablist[0:min(c,abl)]
    ansb=ablist[max(0,abl-c):abl]
    #print(ansa,ansb)
    ans=set(ansa) | set(ansb)
    for i in ans:
        print(i)
if __name__ == '__main__':
    do()

Fixed, accepted submission:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    ans=[]
    for i in range(c):
        ai=a+i
        bi=b-i
        if a<=ai and ai<=b:
            ans.append(ai)
        if a<=bi and bi<=b:
            ans.append(bi)
    ans=sorted(set(ans))
    for i in ans:
        print(i)
    
if __name__ == '__main__':
    do()
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
A, B = map(int, input().split())
print(round(A/B))

Fixed, accepted submission:
A, B = map(int, input().split())
if A == 1 or B == 1:
  print(1)
elif (A*B) % 2 == 0:
  print(A*B//2)
else:
  print(A*B//2+1)
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
while True:
    try:
        print(eval(input()))
    except Exception as e:
        break

Fixed, accepted submission:
while True:
    try:
        print(int(eval(input())))
    except Exception as e:
        break
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

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

ans = 0

for i in range(N):
    ans += i
print(ans)

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

ans = 0

for i in range(N):
    ans += i + 1
print(ans)
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

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

for i in range(1, n):
    print(i)
    a,b = set(s[:i]), set(s[i:])
    if max(len(a),len(b))-max(len(a-b),len(b-a))>x:
        x = max(len(a),len(b))-max(len(a-b),len(b-a))

print(x)

Fixed, accepted submission:
n = int(input())
s = input()
x = 0

for i in range(1, n):
    a,b = set(s[:i]), set(s[i:])
    if len(a&b)>x:
        x = len(a&b)
print(x)
Problem:
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).   Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`.   However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.   Determine if square1001 can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
N,M = map(int, input().split())
field =[]
field.append(list("."*(M+2)))
for i in range(N):
    t = list("."+input()+".")
    field.append(t)
field.append(list("."*(M+2)))
print(field)
res = 1
def dfs(x,y):
    r = 0 
    #field[x][y] = "."
    
    for dx in range(-1,2):
        for dy in range(-1,2):
            if abs(dx+dy) ==1: 
                nx = x + dx
                ny = y + dy
                if field[nx][ny]==".":
                    r+=1
    if r==4: return 0
    else: return 1
                    
        
                
for i in range(0,N+2):
    for j in range(0,M+2):
        if field[i][j] == "W":
            res = res *dfs(i,j)
            
if res:print("Yes")
else:print("No")

Fixed, accepted submission:
N,M = map(int, input().split())
field =[]
field.append(list("."*(M+2)))
for i in range(N):
    t = list("."+input()+".")
    field.append(t)
field.append(list("."*(M+2)))
res = 1
def dfs(x,y):
    r = 0 
    #field[x][y] = "."
    
    for dx in range(-1,2):
        for dy in range(-1,2):
            if abs(dx+dy) ==1: 
                nx = x + dx
                ny = y + dy
                if field[nx][ny]==".":
                    r+=1
    if r==4: return 0
    else: return 1
                    
        
                
for i in range(0,N+2):
    for j in range(0,M+2):
        if field[i][j] == "#":
            res = res *dfs(i,j)
            
if res:print("Yes")
else:print("No")