TnT/CodeNet4Repair huggingface dataset:
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):
import numpy as np

def test(A, B, C):
	if (A<C) & (C<B):
		print('Yes')
	elif (B<C) & (C<A):
		print('Yes')
	else:
		print('No')


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

A=int(A)
B=int(B)
C=int(C)

AB=abs(A-B)
ACB=abs(A-C)+abs(C-B)

if AB==ACB:
	print('Yes')
else:
	print('No')
Problem:
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Incorrect submission (verdict: Wrong Answer):
from collections import deque

n,m = map(int,input().split())
e = [[] for i in range(n)]

for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append([b,c])
    e[b].append([a,-c])

print(e)
dis = [False]*n

def search(x):

    q = deque([])
    dis[x] = 0
    q.append(x)
    while q:
        now = q.pop()
        for nex,d in e[now]:
            if dis[nex] == False:
                dis[nex] = dis[now]+d
                q.append(nex)
            else:
                if dis[nex] != dis[now]+d:
                    print("No")
                    exit()
        
for i in range(n):
    if e[i] and dis[i] == False:
        search(i)
print("Yes")

Fixed, accepted submission:
def main():    
    from collections import deque
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    e = [[] for i in range(n)]

    for i in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        e[a].append([b,c])
        e[b].append([a,-c])


    dis = [float("INF")]*n

    def search(x):

        q = deque([])
        dis[x] = 0
        q.append(x)
        while q:
            now = q.popleft()
            for nex,d in e[now]:
                if dis[nex] == float("INF"):
                    dis[nex] = dis[now]+d
                    q.append(nex)
                else:
                    if dis[nex] != dis[now]+d:
                        print("No")
                        exit()
            
    for i in range(n):
        if e[i] and dis[i] == float("INF"):
            search(i)
    print("Yes")

if __name__ == "__main__":
    main()
Problem:
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.

Incorrect submission (verdict: Wrong Answer):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

def cal(A, N):
    cnt1 = 0
    cnt2 = 0
    for i in range(N):
        for j in range(i+1,N):
            if A[N-1-j] > A[N-1-i]:
                cnt1 += 1
    for i in range(N):
        for j in range(N):
            if A[N-1-i] < A[j]:
                cnt2 += 1
    
    return cnt1, cnt2
    
    
x, y = cal(A,N)

tmp = int(y*(K-1)/2)
ans = K*(tmp + x)
print(int(ans%(10**9+7)))

Fixed, accepted submission:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

def cal(A, N):
    cnt1 = 0
    cnt2 = 0
    for i in range(N):
        for j in range(i+1,N):
            if A[N-1-j] > A[N-1-i]:
                cnt1 += 1
    for i in range(N):
        for j in range(N):
            if A[N-1-i] < A[j]:
                cnt2 += 1
    
    return int(cnt1), int(cnt2)
    
    
x, y = cal(A,N)
R = int(1*10**9 +7)
tmp = K*(K-1)//2
ans =  tmp*y + x*K
print(int(ans%R))
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):
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, c):
    color[v] = c
    for vi, wi in g[v]:
        if vi == p: continue
        if wi % 2: dfs(vi, v, 0)
        else: dfs(vi, v, 1)
    return color

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append((v, w))
    g[v].append((u, w))

color = [0 for _ in range(n)]
for i in dfs(0, -1, 0):
  print(i)

Fixed, accepted submission:
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, c):
    color[v] = c
    for vi, wi in g[v]:
        if vi == p: continue
        if wi % 2: dfs(vi, v, 1-c)
        else: dfs(vi, v, c)
    return color

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append((v, w))
    g[v].append((u, w))

color = [0 for _ in range(n)]
for i in dfs(0, -1, 0):
    print(i)
Problem:
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east.  They start simultaneously at the same point and moves as follows **towards the east** :    * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.   * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever.  How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.

Incorrect submission (verdict: Wrong Answer):
T1, T2 = [int(i) for i in input().split()]
A1, A2 = [int(i) for i in input().split()]
B1, B2 = [int(i) for i in input().split()]

d1 = T1*(A1-B1)
d2 = T2*(A2-B2)

if d1 + d2 == 0:
    print('infinity')

if (d1 > 0 and d2 > 0) or (d1 < 0 and d2 < 0):
    print(0)

if d1 * (d2 - d1) > 0:
    if d1 % (d2 - d1) != 0:
        print(2 * d1 // (d2 - d1) + 1)
    else:
        print(2 * d1 // (d2 - d1))

Fixed, accepted submission:
T1, T2 = [int(i) for i in input().split()]
A1, A2 = [int(i) for i in input().split()]
B1, B2 = [int(i) for i in input().split()]

d1 = T1*(A1-B1)
d2 = T2*(B2-A2)

if d1 == d2:
    print('infinity')

if d1 * (d2 - d1) < 0:
    print(0)

if d1 * (d2 - d1) > 0:
    if d1 % (d2 - d1) != 0:
        print(d1 // (d2 - d1) * 2+ 1)
    else:
        print(d1 // (d2 - d1) * 2)
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())
x=0
for i in range(N):
  x+=i**2
print(x)

Fixed, accepted submission:
N=int(input())
x=0
for i in range(N):
  x+=(i+1)
print(x)
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())
cnt = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(n):
    si = input()
    cnt[si] += 1

print(f'AC x {cnt["AC"]}')
print(f'WA x {cnt["WA"]}')
print(f'TLT x {cnt["TLE"]}')
print(f'RE x {cnt["RE"]}')


Fixed, accepted submission:
n = int(input())
cnt = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(n):
    si = input()
    cnt[si] += 1

print(f'AC x {cnt["AC"]}')
print(f'WA x {cnt["WA"]}')
print(f'TLE x {cnt["TLE"]}')
print(f'RE x {cnt["RE"]}')
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

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

x1 = max(map(int,input().split())) + 1
y1 = min(map(int,input().split()))

if x1 <= y1 and x1 <= y and y1 > x:
    print('No war')
else:
    print('War')

Fixed, accepted submission:
n,m,x,y = map(int,input().split())

x1 = max(map(int,input().split())) + 1
y1 = min(map(int,input().split()))

if x1 <= y1 and x1 <= y and y1 > x:
    print('No War')
else:
    print('War')
Problem:
Takahashi is organizing a party.  At the party, each guest will receive one or more snack pieces.  Takahashi predicts that the number of guests at this party will be A or B.  Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.  We assume that a piece cannot be divided and distributed to multiple guests.

Incorrect submission (verdict: Wrong Answer):
def main():
    a, b = map(int, input().split())
    import math

    print(math.gcd(a,b))
    


if __name__ == "__main__":
    main()


Fixed, accepted submission:
def main():
    a, b = map(int, input().split())
    import math

    print(int(a*b/math.gcd(a,b)))
    


if __name__ == "__main__":
    main()
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):
import collections
a=int(input())
b=[input() for i in range(a)]

c=collections.Counter(b)
n,m=zip(*c.most_common())
n=list(n)
m=list(m)
result=[0]*4
for i in range(len(n)):
    if n[i]=='AC':
        result[0]=m[i]
    if n[i]=='WA':
        result[1]=m[i]
    if n[i]=='TLE':
        result[2]=m[i]
    if n[i]=='RE':
        result[3]=m[i]
print('AC ×',result[0])
print('WA ×',result[1])
print('TLE ×',result[2])
print('RE ×',result[3])
    

Fixed, accepted submission:
import collections
a=int(input())
b=[input() for i in range(a)]

c=collections.Counter(b)
n,m=zip(*c.most_common())
n=list(n)
m=list(m)
result=[0]*4
for i in range(len(n)):
    if n[i]=='AC':
        result[0]=m[i]
    if n[i]=='WA':
        result[1]=m[i]
    if n[i]=='TLE':
        result[2]=m[i]
    if n[i]=='RE':
        result[3]=m[i]
    
print('AC x',result[0])
print('WA x',result[1])
print('TLE x',result[2])
print('RE x',result[3])
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())
C = [ 0 for i in range(4) ]
s2num = {"AC":0, "WA":1, "TLE":2, "RE":3}
num2s = {0:"AC", 1:"WA", 2:"TLE", 3:"RE"}
# read
for i in range(N):
    num = s2num[ input() ]
    C[num] += 1
    #print(num)
# print
for i in range(4):
    print("{} × {}".format( num2s[i], C[i] ))




Fixed, accepted submission:
N = int(input())
C = [ 0 for i in range(4) ]
s2num = {"AC":0, "WA":1, "TLE":2, "RE":3}
num2s = {0:"AC", 1:"WA", 2:"TLE", 3:"RE"}
# read
for i in range(N):
    num = s2num[ input() ]
    C[num] += 1
    #print(num)
# print
for i in range(4):
    print("{} x {}".format( num2s[i], C[i] ))
Problem:
We have a grid with H rows and W columns, where all the squares are initially white.  You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:    * Choose one row, then paint all the squares in that row black.   * Choose one column, then paint all the squares in that column black.  At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.

Incorrect submission (verdict: Wrong Answer):
n, h, w = [int(input()) for i in range(3)]
k = max(h, w)
ans = (n+k-1)//k
print(ans)	 

Fixed, accepted submission:
h, w, n= [int(input()) for i in range(3)]
k = max(h, w)
ans = (n+k-1)//k
print(ans)
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
# coding:utf-8
n = list(map(int, input().split()))
print(n)
if n[0] > n[1]:
    i = n[0]
    n[0] = n[1]
    n[1] = i
    print (str(n[0]) + " " + str(n[1]))
else:
    print (str(n[0]) + " " + str(n[1]))


Fixed, accepted submission:
n = []
i = 0
while i < 3000:
    n = [int(i) for i in input().split()]
    if n[0] == 0 and n[1] == 0:
        break
    m = 0
    if n[0] > n[1]:
        m = n[0]
        n[0] = n[1]
        n[1] = m
    print(str(n[0]) + " " + str(n[1]))
    i += 1
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

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

if S == "keyence":
    print("Yes")
    exit()

for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[:i]+S[j:] == "keyence":
            print("Yes")
            exit()

print("No")

Fixed, accepted submission:
S = input()

if S == "keyence":
    print("YES")
    exit()

for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[:i]+S[j:] == "keyence":
            print("YES")
            exit()

print("NO")
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
val = 1
res = 0
while val <= N:
    val *= 2

print('val = ', val)
mod_2 = divmod(val, 2)
mod_2 = mod_2[0]
print(mod_2)



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

while val <= N:
    val *= 2

mod_2 = divmod(val, 2)
mod_2 = mod_2[0]
print(mod_2)
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):
    st,sp = map(int,input().split())
    ans += abs(sp-st)
print(ans)

Fixed, accepted submission:

N = int(input())
ans = 0
for i in range(N):
    st,sp = map(int,input().split())
    ans += abs(sp-st+1)
print(ans)
Problem:
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
N,K = map(int,input().split())
Alist = np.array(list(map(int,input().split())))
counter = 0
for i,A in enumerate(Alist,0):
    fir_tenti = np.count_nonzero(A>Alist[i:])
    print(fir_tenti)
    counter += (K*(fir_tenti*(K+1)))/2
    second_tenti = np.count_nonzero(A>Alist)
    print(second_tenti)
    counter += second_tenti*K**2-(2*second_tenti*K)+second_tenti/2
print(int(counter%(10**9+7)))

Fixed, accepted submission:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
mod = 10**9 + 7

def sum_n(n):
    return (n * (n+1))//2

ans = 0
left = [0] * N
right = [0] * N
for i in range(N):
    a = Alist[i]
    in_left = True
    for j in range(N):
        if i == j:
            in_left = False
            continue
        else:
            if Alist[j] < a:
                if in_left:
                    left[i] += 1
                else:
                    right[i] += 1
    ans += right[i] * sum_n(K)
    ans += left[i] * sum_n(K-1)
    ans %= mod
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):

example = ('5', '7', '5')
five = 0
seven = 0
ipt = []
s = input(">")
s = s.split()

for i in s:
    if i == '5':
        five += 1
    elif i == '7':
        seven += 1

if five == 2 and seven == 1:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:

example = ('5', '7', '5')
five = 0
seven = 0
ipt = []
s = input()
s = s.split()

for i in s:
    if i == '5':
        five += 1
    elif i == '7':
        seven += 1

if five == 2 and seven == 1:
    print("YES")
else:
    print("NO")
Problem:
AtCoder Mart sells 1000000 of each of the six items below:    * Riceballs, priced at 100 yen (the currency of Japan) each   * Sandwiches, priced at 101 yen each   * Cookies, priced at 102 yen each   * Cakes, priced at 103 yen each   * Candies, priced at 104 yen each   * Computers, priced at 105 yen each  Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible.   (Ignore consumption tax.)

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

nokori = x%100
max_n = x//100
print(nokori//5 + nokori%5//4 + nokori%5%4//3 + nokori%5%4%3//2 + nokori%5%4%3%2)
if max_n < nokori//5 + nokori%5//4 + nokori%5%4//3 + nokori%5%4%3//2 + nokori%5%4%3%2:
    print(0)
else:
    print(1)


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

nokori = x%100
max_n = x//100

if max_n < nokori//5 + nokori%5//4 + nokori%5%4//3 + nokori%5%4%3//2 + nokori%5%4%3%2:
    print(0)
else:
    print(1)
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
X=int(input())
A=int(input())
B=int(input())
print(X-A-B)

Fixed, accepted submission:
X=int(input())
A=int(input())
B=int(input())
print((X-A-B)%B)
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
def testcase(x):
    print("Case {}: {}".format(str(x),str(x)))


Fixed, accepted submission:
c = 0
while True:
    n = input()
    if n == '0':
        break
    c += 1
    print('Case ' + str(c) + ': ' + n)
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()

ans = 0
for sakaime in range(N):
    left = S[:sakaime]
    right = S[sakaime:]
    cnt = 0
    for c in left:
        if c in right:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Fixed, accepted submission:
N = int(input())
S = input()
import string
abcs = string.ascii_lowercase

ans = 0
for sakaime in range(N):
    cnt = 0
    left = S[:sakaime]
    right = S[sakaime:]
    for alpha in abcs:
        if alpha in left and alpha in right:
            cnt += 1
    ans = max(ans, cnt)
    
print(ans)
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):
n = int(input())
AB = []
for i in range(n):
    a,b=map(int,input().split())
    AB.append([a,b])
CD = []
for i in range(n):
    c,d=map(int,input().split())
    CD.append([c,d])
coutAB = []
coutCD = []
count = 0
for i in range(n):
    for j in range(n):
        if AB[i][0] <= CD[j][0] and AB[i][1] <= CD[j][1]:
            if AB[i] not in coutAB and CD[j] not in coutCD:
                count+=1
                coutAB.append(AB[i])
                coutCD.append(CD[j])
print(coutAB)
print(coutCD)
print(count)

Fixed, accepted submission:
N = int(input())
x = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: -x[1])
y = sorted([list(map(int, input().split())) for _ in range(N)])

cnt = 0
for c, d in y:
  for a, b in x:
    if a < c and b < d:
      x.remove([a, b])
      cnt += 1
      break

print(cnt)
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
N, M = map(int, input().split())

dp = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    dp[a-1][b-1] += 1
    dp[b-1][a-1] += 1
    print(dp)
for i in range(N):
    print(sum(dp[i]))

Fixed, accepted submission:
n, m = map(int,input().split())
l = []
for i in range(m):
  l += list(map(int, input().split()))
for i in range(1, n+1):
  print(l.count(i))