Problem:


Score : 200 points

Problem Statement

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?

Constraints

2≤N,M≤50

1≤a_i,b_i≤N

a_i ≠ b_i

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N M
a_1 b_1
:  
a_M b_M

Output

Print the answer in N lines.
In the i-th line (1≤i≤N), print the number of roads connected to city i.

Sample Input 1

4 3
1 2
2 3
1 4

Sample Output 1

2
2
1
1

City 1 is connected to the 1-st and 3-rd roads.

City 2 is connected to the 1-st and 2-nd roads.

City 3 is connected to the 2-nd road.

City 4 is connected to the 3-rd road.

Sample Input 2

2 5
1 2
2 1
1 2
2 1
1 2

Sample Output 2

5
5

Sample Input 3

8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8

Sample Output 3

3
3
2
2
2
1
1
2



Sample input:
4 3
1 2
2 3
1 4


Sample output:
2
2
1
1

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())

xy = [map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]
M = []


Z = x + y
Z = sorted(Z)

c = collections.Counter(Z)

V = list(c.values())

for i in range(len(V)):
    print(V[i])

Submission status: Wrong Answer

Solution code:
import itertools
from collections import Counter
from typing import List


def answer(n: int, m: int, ab_s: List[List[int]]) -> List[int]:
    counter = Counter(itertools.chain.from_iterable(ab_s))
    roads = list(i[1] for i in sorted(counter.items()))
    return roads


def main():
    n, m = map(int, input().split())
    ab_s = [list(map(int, input().split())) for _ in range(m)]
    for i in answer(n, m, ab_s):
        print(i)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
L=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    L[a-1][b-1]=1
    L[b-1][a-1]=1
for i in range(n):
    print(sum(L[i]))

Submission status: Wrong Answer

Solution code:
N, M, *cnt = open(0).readline().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
s = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    s[a-1].append(b)
    s[b-1].append(a)
for i in s:
    print(len(set(i)))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
al=[]
bl=[]
for i in range(m):
  a,b=map(int,input().split())
  al.append(a)
  bl.append(b)

for i in range(1,m+1):
  print(al.count(i)+bl.count(i))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
al=[]
bl=[]
for i in range(m):
  a,b=map(int,input().split())
  al.append(a)
  bl.append(b)

for i in range(m+1):
  print(al.count(i)+bl.count(i))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

WAY = [[] for _ in range(N+1)]
for a,b in AB:
  WAY[a].append(b)
  WAY[b].append(a)
  
ans = []
for i in range(1,N+1):
  c = len(set(WAY[i]))
  ans.append(c)
  
print("\n".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
import collections as c
n,m=map(int,input().split())
print(*[i[1] for i in sorted(c.Counter(sum([[*map(int,input().split())] for _ in range(m)],[])).items())],sep='\n')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l={}
for i in range(m):
    p,q=map(int,input().split())
    if not p in l:
        l[p]=1
    else:
        l[p]+=1
    if not q in l:
        l[q] = 1
    else:
        l[q] += 1
for k,v in sorted(l.items()):
    print(v)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l={}
for i in range(m):
    p,q=map(int,input().split())
    if not p in l:
        l[p]=1
    else:
        l[p]+=1
    if not q in l:
        l[q] = 1
    else:
        l[q] += 1
print(*l.values(), sep='\n')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [0] * (N + 1)

for i in range(M):
    a,b = map(int,input().split())

    A[a] += 1
    A[b] += 1

for a in A:
    if a != 0:
        print(a)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
 
a = []
 
for i in range(m):
  a1, a2 = map(int, input().split())
  a.append(a1)
  a.append(a2)
 
for s in range(n):
  print(a.count(s))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
ab = []
for _ in range(M):
    ab.append(int(input().replace(' ','')))
#print(ab)
abc = ''
for i in ab:
    abc += str(i)
#print(abc)
for j in range(1,N+1):
    print(abc.count(str(j)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
lst = [[] for i in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    lst[a-1].append(b-1)
    lst[b-1].append(a-1)
print(lst)

for v in lst:
    print(len(v))

Submission status: Wrong Answer

Solution code:
N,M = map(int,(input().split()))
ab = [int(input().replace(' ',''))for _ in range(M)]
#print(ab)
abc=''
ans = []
for i in ab:
    abc+=str(i)
#print(int(abc))

for j in range(1,N+1):
    print(abc.count(str(j)))

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
count = [[0 for i in range(n)] for h in range(n)]
for i in range(m):
    a,b  = lr()
    a-=1
    b-=1
    a,b = min(a,b), max(a,b)
    count[a][b] = 1
    count[b][a] = 1
for i in range(n):
    print(sum(count[i]))

Submission status: Wrong Answer

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
from collections import defaultdict

d = defaultdict(int)
for i in range(M):
    a,b = MI()
    d[a] += 1
    d[b] += 1

print(sum(d[i] for i in d.keys()))

Submission status: Wrong Answer

Solution code:
n, m = map(int , input().split())
am = [list(map(int,input().split())) for _ in range(m)]

route = {}
for a in am:
  if a[0] in route:
    route[a[0]] += 1
  else :
    route[a[0]] = 1
  if a[1] in route:
    route[a[1]] += 1
  else :
    route[a[1]] = 1 

routes = sorted(route.items())
for r in routes:
  print(r[1])

Submission status: Wrong Answer

Solution code:
N, M = input().split(' ')
N = int(N)
M = int(M)
citys = []
for i in range(M):
  a, b = input().split(' ')
  a = int(a)
  b = int(b)
  citys.append(a)
  citys.append(b)
print(citys)
for i in range(1, N+1):
  print(citys.count(i))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
route_lists = [input().split() for i in range(m)]
new_lists = []
for i in route_lists:
  for j in range(2):
    new_lists.append(i[j])

new_lists.sort()
sets = set(new_lists)
num_lists = list(sets)
num_lists.sort()
for i in num_lists:
  print(new_lists.count(i))

Submission status: Wrong Answer

Solution code:
N,M = [int(i) for i in input().split()]
list = []

for i in range(M):
  a,b = [int(i) for i in input().split()]
  list.append(a)
  list.append(b)
  
for i in range(N):
  print(list.count(i))

Submission status: Wrong Answer

Solution code:
n,m=[int(i) for i in input().split()]
city_dic={}

for i in range(m):
    ab_list=[int(i) for i in input().split()]
    for j in ab_list:
        if j not in city_dic:
            city_dic[j]=1
        else:
            city_dic[j]+=1
            
#print(city_dic)
key_list=sorted(city_dic)

for i in key_list:
    print(city_dic[i])

Submission status: Wrong Answer

Solution code:

N,M = map(int,input().split())
adj = [[0]*N for _ in range(N)]
intx = lambda x: int(x)-1
for i in range(M):
    a,b = map(intx,input().split())
    #print(a,b)
    adj[a][b] = 1
    adj[b][a] = 1
for i in range(N): 
    print(sum(adj[i]))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
load = []
load.extend(map(int, input().split()))

for i in range(n):
    print(load.count(i+1))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for i in range(1, N):
    d[i] = 0
for _ in range(M):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1

for i in d.values():
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1

for i in d.values():
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from operator import itemgetter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in my_count:
    print(i[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(M):
    a, b = list(map(int, input().split()))
    my_count[a] += 1
    my_count[b] += 1
for i in my_count.values():
    print(i)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

pairs = []
for i in range(M):
    pairs.append(list(map(int, input().split())))
    
for i in range(1,N+1):
    s = set([])
    for pair in pairs:
        if i in pair:
            s |= set(pair)
    print(len(s)-1)

Submission status: Wrong Answer

Solution code:
N, M =map(int, input().split())
ans = []
for i in range(M):
    a, b = map(int, input().split())
    ans.append(a)
    ans.append(b)

print(ans)
for i in range(1,N+1):
    print(ans.count(i))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    A[a][b] = 1
    A[b][a] = 1
for i in range(1, N+1):
    sum = 0
    for j in range(1, N+1):
        sum += A[i][j]
    print(sum)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
r = [0]*N
for _ in range(M):
    a, b = map(int, input().split())
    r[a-1]+1
    r[b-1]+1
for rr in r:
    print(rr)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
r = [[0]*N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    r[a][b] = 1
    r[b][a] = 1
for rr in r:
    print(sum(rr))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
city_l=[]
for i in range(M):
    a,b=map(int,input().split())
    city_l.append(a)
    city_l.append(b)
print(city_l)
for i in range(1,N+1):
    print(city_l.count(i))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
ans = defaultdict(int)
for _ in range(m):
    a, b = map(int, input().split())
    ans[a - 1] += 1
    ans[b - 1] += 1
for _, v in sorted(ans.items()):
    print(v)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
ans = defaultdict(int)
for q in range(m):
    ab = list(map(int, input().split()))
    if ab[0] != ab[1]:
        ans[ab[0]] += 1
        ans[ab[1]] += 1
for _, v in sorted(ans.items()):
    print(v)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
ans = defaultdict(int)
for q in range(m):
    ab = list(map(int, input().split()))
    ans[ab[0]] += 1
    ans[ab[1]] += 1
for _, v in sorted(ans.items()):
    print(v)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
result = []
for i in range(m):
    result.append(input().split())
result = sum(result, [])
for i in range(1, n+1):
    count = result.count(str(i))
    if count == 0:
        break
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m = map(int, input().split(' '))

array = np.zeros(n)

for i in range(m):
    a, b = map(int, input().split(' '))
    array[a-1] += 1
    array[b-1] += 1
    
for number in array:
    print(number)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
res = {}
for _ in range(M):
    a,b = map(int,input().split())
    if a in res.keys():
        res[a] += 1
    else:
        res[a] = 1
    if b in res.keys():
        res[b] += 1
    else:
        res[b] = 1
for key in sorted(res.keys()):
    print(res[key])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
res = {}
for _ in range(M):
    a,b = map(int,input().split())
    if a in res.keys():
        res[a] += 1
    else:
        res[a] = 1
    if b in res.keys():
        res[b] += 1
    else:
        res[b] = 1
for key,value in sorted(res.items()):
    print(value)

Submission status: Wrong Answer

Solution code:
N, M  = map(int, input().split())

from collections import defaultdict

d = defaultdict(int)

for i in range(M):
    x, y  = map(int, input().split())
    d[x] += 1
    d[y] += 1

for k, v in sorted(d.items()):
    print(v)

Submission status: Wrong Answer

Solution code:
import collections

def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(m)]
    ab_f = [flatten for inner in  ab for flatten in inner]
    c = collections.Counter(ab_f)
    c_s = sorted(c.items())
    for i in (c_s):
        print(i[1])
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
dd = {}
n, m = map(int, input().split())
for _ in range(m):
    a, b = map(int, input().split())
    dd[a] = dd.get(a,0) + 1
    dd[b] = dd.get(b,0) + 1
for i in sorted(dd.keys()):
    print(dd[i])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a_all = []
b_all = []
for i in range(m):
    a,b = map(int,input().split())
    a_all.append(a-1)
    b_all.append(b-1)
for j in range(n):
    c = set()
    for k in range(m):
        if a_all[k] == j:
            c.add(b_all[k])
        if b_all[k] == j:
            c.add(a_all[k])
    print(len(c))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

glaf = [[] for i in range(N)]

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ll = [0] + [ 0 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    ll[a] += 1
    ll[b] += 1
for l in ll[1:]:
    print()

Submission status: Wrong Answer

Solution code:
def ABC_61_B():
    N,M = map(int, input().split())
    t = [ 0 for _ in range(N)]
    t2 = [ 0 for _ in range(N)]

    for i in range(N):
        t[i] = '0'
        t2[i] = '0'

    for i in range(M):
        a,b = map(str, input().split())
        t[int(a)-1] = str(t[int(a)-1])+b
        t[int(b)-1] = str(t[int(b)-1])+a

    for i in range(N):
        t2=list(t[i])
        print(len(t2)-1)

if __name__ == '__main__':

    ABC_61_B()

Submission status: Wrong Answer

Solution code:
def ABC_61_B():
    N,M = map(int, input().split())
    t = [ 0 for _ in range(N)]
    t2 = [ 0 for _ in range(N)]

    for i in range(N):
        t[i] = '0'
        t2[i] = '0'

    for i in range(M):
        a,b = map(str, input().split())
        t[int(a)-1] = str(t[int(a)-1])+b
        t[int(b)-1] = str(t[int(b)-1])+a

    for i in range(len(t)):
        t2=list(t[i])
        print(len(t2)-1)

if __name__ == '__main__':

    ABC_61_B()

Submission status: Wrong Answer

Solution code:
def ABC_61_B():
    N,M = map(int, input().split())
    t = [ 0 for _ in range(N)]
    t2 = [ 0 for _ in range(N)]

    for i in range(M):
        a,b = map(str, input().split())
        t[int(a)-1] = str(t[int(a)-1])+b
        t[int(b)-1] = str(t[int(b)-1])+a

    for i in range(len(t)):

        if int(t[i])!=0:
            t2=list(t[i])
            print(len(t2)-1)

if __name__ == '__main__':

    ABC_61_B()

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())

mat = [[0] * n] * n
mat = np.array(mat)

for i in range(m):
    a, b = map(int, input().split())

    tar1 = mat[a - 1, b - 1]
    tar2 = mat[b - 1, a - 1]
    if (tar1 == 0):
        mat[a - 1, b - 1] = 1

    if (tar2 == 0):
        mat[b - 1, a - 1]= 1

#print(mat)
for i in range(n):
    ans = np.sum(mat[i, :])
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())

mat = [[0] * n] * n
mat = np.array(mat)

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


for i in range(n):
    ans = np.sum(mat[i, :])
    print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

mat = [[0] * n] * n

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


for i in range(n):
    ans = sum(mat[i])
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int, input().split()))
from collections import defaultdict
d=defaultdict(list)
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)

for k in sorted(d):
    print(len(d[k]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, M = map(int, input().split())
R = []
for i in range(M):
  R += list(map(int, input().split()))
R = Counter(R)
K = sorted(R)
for k in K:
  print(R[k])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N, M = map(int, input().split())
R = []
for i in range(M):
  R += list(map(int, input().split()))
R = Counter(R)
for i in R.values():
  print(i)

Submission status: Wrong Answer

Solution code:
n, m=map(int, input().split())
table=[[0]*50 for i in range(50)]

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

for i in range(50):
    ans=0
    for j in range(50):
        if table[j][i]!=0:
            ans+=1

    if ans!=0:
        print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
city = {}
for i in ab:
  for j in i:
    if j not in city:
      city[j] = 1
    else:
      city[j] += 1
for number in range(n):
  if number in city:
    print(city[number])
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
city = {}
for i in ab:
  for j in i:
    if j not in city:
      city[j] = 1
    else:
      city[j] += 1
for k, v in sorted(city.items()):
  print(v)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
city = {}
for i in ab:
  for j in i:
    if j not in city:
      city[j] = 1
    else:
      city[j] += 1
for v in city.values():
  print(v)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N, M = map(int, input().split())

memo = defaultdict(int)

for _ in range(M):
    a, b = map(int, input().split())
    memo[a] += 1
    memo[b] += 1

memo = sorted(memo.items(), key=lambda x: x[0])

for m in memo:
    print(m[1])

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())

c=[input() for i in range(b)]
sum=0
d=[]

for k in range(1,a+1):
    for j in range(b):
    
        sum=sum+c[j].split()[0].count(str(k))+c[j].split()[1].count(str(k))
    d.append(sum)
    sum=0
for m in d:
    print(m)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    n, m = map(int, input().split())
    ABs = [list(map(int, input().split())) for _ in range(m)]
    ABs = [b for a in ABs for b in a]
    anss = Counter(ABs)
    anss = sorted(anss.items(), key=lambda x: x[0])
    for ans in anss:
        print(ans[1])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    n, m = map(int, input().split())
    ABs = [list(map(int, input().split())) for _ in range(m)]
    ABs = [b for a in ABs for b in a]
    anss = Counter(ABs)
    for ans in anss.values():
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m = tuple(map(int,input().split()))

r = [[0]*n for _ in [0]*n]

for _ in range(m):
  a,b = tuple(map(int,input().split()))
  r[a-1][b-1] = 1
  r[b-1][a-1] = 1

for r_i in r:
  print(sum(r_i))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
mat = [[0 for _ in range(N)] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    mat[a][b] = 1
    mat[b][a] = 1
for i in range(N):
    cnt = 0
    for j in range(N):
        if mat[i][j] != 0:
            cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())

graph=[set() for _ in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  graph[a].add(b)
  graph[b].add(a)
#print(graph)  

for i in range(1,N+1):
  print(len(graph[i]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)
for i in range(N):
    print(c.count(i+1))
print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)

C = np.zeros((N,1),dtype = 'int')
for i in range(len(C)):
    C[i,0] = c.count(i+1)
print(C)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)
import numpy as np
C = np.zeros((N,1),dtype = 'int')
for i in range(len(C)):
    C[i,0] = c.count(i+1)
print(C)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)

C = np.zeros((max(c),1),dtype = 'int')
for i in range(len(C)):
    C[i,0] = c.count(i+1)
print(C)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)

C = np.zeros((max(c),1),dtype = 'int')
for i in range(len(C)):
    C[i,0] = c.count(i)
print(C)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(m)]
a = "".join(a)
for q in range(1, n + 1):
    print(a.count(str(q)))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

c = ""
for _ in range(M):
  a,b = input().split()
  c += a+b
  
for i in range(1,N+1):
  print(c.count(str(i)))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
roads = [0] * n
for a, b in ab:
    roads[a-1] += 1
    roads[b-1] += 1
print(roads)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

[N, M] = list(map(int, stdin.readline().rstrip().split()))

a = []
for i in range(M):
    a.append(list(map(int, stdin.readline().rstrip().split())))

city = [[] for i in range(N+1)]

for i in range(M):
    [s, d] = a[i]
    city[s].append(d)
    city[d].append(s)

for i in range(1, N+1):
    if len(city[i]) > 0:
        print(len(city[i]))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

[N, M] = list(map(int, stdin.readline().rstrip().split()))

a = []
for i in range(M):
    a.append(list(map(int, stdin.readline().rstrip().split())))

city = []
for i in range(N):
    city.append([])

for i in range(M):
    [s, d] = a[i]
    city[s-1].append(d-1)
    city[d-1].append(s-1)

for i in range(N):
    if len(city[i]) > 0:
        print(len(city[i]))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
L=[]
for i in range(b):
   L.append(list(map(int,input().split())))
for i in range(b):
      print(L.count(i+1))

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())

num = []
for i in range(M):
    a, b = map(int, input().split())
    num.append(a)
    num.append(b)
    
num.sort()
count = collections.Counter(num)
countkey = list(count.keys())
for i in countkey:
    print(count[i])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().rstrip().split(' '))
G = [[]]*n
for i in range(m):
  a,b = map(int,input().rstrip().split(' '))
  a-=1
  b-=1
  G[a].append(b)
  G[b].append(a)

for i in range(n):
  print(len(G[i]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = [0] * N
for _ in range(M):
  a, b = map(int, input().split())
  ans[a - 1] += 1
  ans[b - 1] += 1
print(ans, sep="\n")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = [0] * N
for i in range(M):
  a, b = map(int, input().split())
  ans[a - 1] += 1
  ans[b - 1] += 1
for i in range(N):
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=[0]*n
print(A)
for i in range(m):
    a,b=map(int,input().split())
    A[a-1] += 1
    A[b-1] += 1
for h in range(n):
    print(A[h])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
for _ in range(M):
    a, b = input().split()
for i in range(1, N+1):
    print(a.count("i")+b.count("i"))

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M = list(map(int,input().split()))
a = list(np.array([input().split() for i in range(M)]).reshape(-1))
a = [int(i) for i in a]

for i in range(1,M+2):
	print(a.count(i))

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M = list(map(int,input().split()))
a = list(np.array([input().split() for i in range(M)]).reshape(-1))
a = [int(i) for i in a]

for i in range(1,M+1):
	print(a.count(i))

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M = list(map(int,input().split()))
a = np.array([input().split() for i in range(M)])
a = [int(i) for i in a.reshape(-1)]
all_type = set(a)

for i in all_type:
	print(a.count(i))

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

N,M = list(map(int,input().split()))
a = np.array([input().split() for i in range(M)])
a = [int(i) for i in a.reshape(-1)]

count = collections.Counter(a)

for i in sorted(count.keys()):
	#print(i)
	print(count[i])

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

N,M = list(map(int,input().split()))
a = np.array([input().split() for i in range(M)])
a = [int(i) for i in a.reshape(-1)]

count = collections.Counter(a)

for i in count.keys():
	print(count[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
r=[0]*n
for _ in range(m):
    a,b=map(int, input().split())
    r[a-1]+=1
    r[b-1]+=1

for i in r:
    if i!=0:
        print(i)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = 0
#最後にNoneを消す。あとはsetで重複を消す。
roads_memo = [[None] for i in range(N)]

for _ in range(M):
    ai, bi = map(int, input().split())
    roads_memo[ai-1].append(bi)
    roads_memo[bi-1].append(ai)

for memo in roads_memo:
    del memo[0]
    memo = set(memo)
    print(len(memo))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x_l=[]
for i in range(m):
    x_l+= list(map(int,input().split()))

print(n,m,x_l)

dic={}
for i in x_l:
    if i not in dic:
        dic[i]=1
    else:dic[i]+=1
print(dic)
for i in range(1,n+1):
    if i not in dic:
        print(0)
    else: print(dic[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x_l=[]
for i in range(m):
    x_l+= list(map(int,input().split()))

# print(n,m,x_l)

dic={}
for i in x_l:
    if i not in dic:
        dic[i]=1
    else:dic[i]+=1
# print(dic)
for i in range(n+1):
    if i not in dic:
        continue
    else: print(dic[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x_l=[]
for i in range(m):
    x_l+= list(map(int,input().split()))

# print(n,m,x_l)

dic={}
for i in x_l:
    if i not in dic:
        dic[i]=1
    else:dic[i]+=1
# print(dic)
for i in range(m+1):
    if i not in dic:
        continue
    else: print(dic[i])

Submission status: Wrong Answer

Solution code:
# abc061_b.py

N, M = map(int,input().split())
ab = []
for i in range(M):
    a,b = map(int,input().split())
    ab.append(a)
    ab.append(b)
ab.sort()
pre = 0
cnt = 0
for i in ab:
    if pre == i:
        cnt += 1
    else:
        if pre != 0:
            cnt += 1
            print(cnt)
            cnt = 0
    pre = i
cnt += 1
print(cnt)