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: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
L = [0 for _ in range(N)]
for _ in range(M):
    x , y = map(int,input().split())
    L[x-1] += 1
    L[y-1] += 1
for x in L:
    print(x)

Submission status: Accepted

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

for _ in range(m):
    A.extend(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
def func():
    pass


def main():
    n, m = map(int, input().split())
    r = []
    for i in range(m):
        a, b = map(int, input().split())
        r.append((a, b))

    ans = [0] * n
    for ri in r:
        a, b = ri[0], ri[1]
        ans[a - 1] += 1
        ans[b - 1] += 1

    for i in ans:
        print(i)


def main2():
    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 ans:
        print(i)


if __name__ == '__main__':
    main2()

Submission status: Accepted

Solution code:
def func():
    pass


def main():
    n, m = map(int, input().split())
    r = []
    for i in range(m):
        a, b = map(int, input().split())
        r.append((a, b))

    ans = [0] * n
    for ri in r:
        a, b = ri[0], ri[1]
        ans[a - 1] += 1
        ans[b - 1] += 1

    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
(n, m) = map(int, input().split())
roads = []
for _ in range(m):
    (ai, bi) = map(int, input().split())
    roads.append([ai, bi])
nums = [0 for _ in range(n)]
for road in roads:
    nums[road[0] - 1] += 1
    nums[road[1] - 1] += 1

for num in nums:
    print(num)

Submission status: Accepted

Solution code:
n,m = (input().split())
n,m = int(n),int(m)
r = []

for i in range(m):
    r = r + input().split()
for i in range(1,n+1):
    print(r.count(str(i)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = [0] * n

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

for i in range(n):
    print(A[i])

Submission status: Accepted

Solution code:
n,m=(int(i) for i in input().split())
#print(n,m)
list1=[0 for i in range(n)]
#print(list1)

for k in range(m):
  a,b=(int(i) for i in input().split())
  for j in range(1,n+1):
    if j==a:
      list1[j-1]+=1
    if j==b:
      list1[j-1]+=1
      
for i in range(n):
  print(list1[i])

Submission status: Accepted

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

[[road.append(x) for x in input().split()] for y in range(m)]

for i in range(1, n+1):
    print(road.count(str(i)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
listRoad = [0]*n
index=0
while index < m:
    a, b = map(int, input().split())
    listRoad[a-1]+=1
    listRoad[b-1]+=1
    index+=1

for road in listRoad:
    print(road)

Submission status: Accepted

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

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


for i in range(0,N):
	sum = 0
	for j in range(0,N):
		sum += w[i][j]
	print(sum)

Submission status: Accepted

Solution code:
import sys
N,M = [int(n) for n in input().split()]

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

Submission status: Accepted

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

roads = [0]*N
for i in range(N):
    roads[i]=sum(cities[i])
    print(roads[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n,m= (int(i) for i in input().split())
ans =np.zeros(n,dtype=int)
for i in range(m):
 a,b= (int(i) for i in input().split())
 ans[a-1] += 1
 ans[b-1] += 1
for j in ans:
 print(j)

Submission status: Accepted

Solution code:
int_n, int_m = map(int, input().split())

roads = dict()

for i in range(int_m):
    road = tuple(map(int, input().split()))

    for r in road:
        if r in roads:
            roads[r] += 1
        else:
            roads[r] = 1


for i in range(1, int_n + 1):
    print("0" if i not in roads else roads[i])

Submission status: Accepted

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[i])

Submission status: Accepted

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

for i in range(m):
    for j in range(2):
        ans[bridges[i][j]-1] += 1

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

Submission status: Accepted

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

for j in range(N):
    print(a.count(j + 1) + b.count(j + 1))

Submission status: Accepted

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

Submission status: Accepted

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

R = [0] * (N + 1)

for a, b in AB:
    R[a] += 1
    R[b] += 1

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = [0] * n

for i in range(m):
    x=input().split()
    ans[int(x[0])-1]+=1
    ans[int(x[1])-1]+=1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest061-B
#  https://atcoder.jp/contests/abc061/tasks/abc061_b

def  solveProblem(cityNumber,roadList):
	cityPassList = [0 for _ in range(0,cityNumber,+1)]
	for fromToList in roadList:
		fromCity = fromToList[0]-1
		toCity = fromToList[1]-1
		cityPassList[fromCity]=cityPassList[fromCity]+1
		cityPassList[toCity]=cityPassList[toCity]+1

	answer = cityPassList
	return answer


if __name__ == '__main__':
	N,M=map(int,input().strip().split(' '))
	roadRange = range(0,M,+1)
	roadList=[]
	for _ in roadRange:
		roadList.append(list(map(int,input().strip().split(' '))))
	solution=solveProblem(N,roadList)
	for cityCount in solution:
		print("{}".format(cityCount))

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, M = il()
AB = iml(M)
s = {i: 0 for i in range(1, N + 1)}
for ab in AB:
    s[ab[0]] += 1
    s[ab[1]] += 1

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
dic={}
for i in range(m):
  x,y=map(int,input().split())
  if x in dic:
    dic[x]+=1
  else:
    dic[x]=1
  if y in dic:
    dic[y]+=1
  else:
    dic[y]=1
for i in range(1,n+1):
  try:
    print(dic[i])
  except:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for r in road:
    print(r)

Submission status: Accepted

Solution code:
def abc061_b():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = map(int, input().split())

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


abc061_b()

Submission status: Accepted

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

for i in range(m):
    a += map(int,input().split())
for j in range(1,n+1):
    print(a.count(j))
#コピペです。

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
temp = input().rstrip().split(" ")
N = int(temp[0])
M = int(temp[1])
list = [0] * N
for i in range(M):
    temp = input().rstrip().split(" ")
    a = int(temp[0])
    b = int(temp[1])
    list[a-1] += 1
    list[b-1] += 1
for answer in list:
    print(answer)

Submission status: Accepted

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

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

for a in count:
    print(a)

Submission status: Accepted

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 ans:
    print(i)

Submission status: Accepted

Solution code:
N, _, *R = open(0).read().split()
for i in range(int(N)):
    print(R.count(str(i + 1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a , b = map(int,input().split())
k = []
for i in range(b):
    t,n = map(int,input().split())
    k.append(t)
    k.append(n)
    
import collections

v = collections.Counter(k)
for i in range(a):
    print (v[i+1])

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
L=[0]*n

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

for i in range(n):
    print(L[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n, m = map(int, input().split())

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

    for cit in counter:
        print(cit)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d = {}
for i in range(1,N+1):
  d[i] = 0

for i in range(M):
  a, b = A[i][0], A[i][1]
  d[a] += A[i].count(a)
  d[b] += A[i].count(b)

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,_,*R=open(0).read().split()
for i in range(int(N)):print(R.count(str(-~i)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

N,M = [int(i) for i in input().split()]
node = []
for ii in range(M) :
    node.extend([int(i) for i in input().split()])

c = collections.Counter(node)
for i in range(1,N+1) :
    print(c[i])

Submission status: Accepted

Solution code:
N,  M = [int(i) for i in input().split()]
cities = {}
for i in range(N):
    cities[i+1] = 0
for i in range(M):
    for c in [int(i) for i in input().split()]:
        cities[c] += 1
for key, val in sorted(cities.items()):
    print(val)

Submission status: Accepted

Solution code:
from itertools import chain
N, M = map(int, input().split())
C = chain.from_iterable([input().split() for _ in range(M)])
hist = {n + 1: 0 for n in range(N)}
for c in C:
    hist[int(c)] += 1
for v in hist.values():
    print(v)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().strip().split()]
A=[]
for i in range(M):
    A.append(input().strip().split())
B =[]
for i in range(M):
    B.append(int(A[i][0]))
    B.append(int(A[i][1]))
for i in range(N):
    print(B.count(i+1))

Submission status: Accepted

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

for i in range(m):
    a += map(int,input().split())
for j in range(1,n+1):
    print(a.count(j))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
  print(sum(roads[i]))

Submission status: Accepted

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

road=[0]*N

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

for i in range(N):
    print(road[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
from collections import defaultdict
n, m = map(int, input().split())
s = []
for i in range(m):#h:高さ
    s.append([int(m) for m in input().split()])

d = defaultdict(int)
#e = defaultdict(int)
for i in range(1, n + 1):
    d[i] = 0
for i in range(m):
    d[s[i][0]] += 1
    d[s[i][1]] += 1
for i in range(1, n + 1):
    print(d[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N, M = map(int, input().split())

lst=[]
for _ in range(M):
    lst += input().split()
for i in range(1, N+1):
    print(lst.count(str(i)))

Submission status: Accepted

Solution code:
# https://beta.atcoder.jp/contests/abc061/tasks/abc061_b


def solve1():
    n, m = map(int, input().split())
    roads = []
    for _ in range(m):
        city = map(int, input().split())
        for c in city:
            roads.append(c)

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


def solve():
    n, m = map(int, input().split())
    roads = {}

    for i in range(1, n+1):
        roads[i] = 0

    for _ in range(m):
        road = input().split()
        for r in road:
            roads[int(r)] += 1

    for road in roads.values():
        print(road)


if __name__ == '__main__':
    # solve()
    solve1()

Submission status: Accepted

Solution code:
# https://beta.atcoder.jp/contests/abc061/tasks/abc061_b


def solve():
    n, m = map(int, input().split())
    roads = {}

    for i in range(1, n+1):
        roads[i] = 0

    for _ in range(m):
        road = input().split()
        for r in road:
            roads[int(r)] += 1

    for road in roads.values():
        print(road)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

for i in adj_nums:
    print(i)

Submission status: Accepted

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

count = [0 for x in range(n)]

for i in range(m):
	a, b =list(map(int, input().split()))
	count[a-1] += 1
	count[b-1] += 1
	
for y in count:
	print(y)

Submission status: Accepted

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

Submission status: Accepted

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[i])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = []
ans = [0]*n
for i in range(m):
  a.append(list(map(int,input().split())))
for i in range(m):
  for j in range(n):
    ans[j] += a[i].count(j+1)
for i in range(n):
  print(ans[i])

Submission status: Accepted

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

for cityNum in range(1,n+1):
    print(roads.count(cityNum))

Submission status: Accepted

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

Submission status: Accepted

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

for cityNum in range(1,n+1):
    ans = 0
    for ab in abList:
        ans += ab.count(cityNum)
    print(ans)

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())

result = [0]*N
for i in range(M):
	a,b = (int(x) for x in input().split())
	result[a-1] += 1
	result[b-1] += 1

for i in result:
	print(i)

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
A = [0 for i in range(N)]
for i in range(M):
    m = list(map(int, input().split()))
    A[m[0]-1] += 1
    A[m[1]-1] += 1
for i in A:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
road = [[int(i) for i in input().split()] for j in range(M)]
road_s = [i[0] for i in road]
road_g = [i[1] for i in road]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

t = [0] * (N + 1)

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#061-B
n,m=map(int,input().split())
r=[0 for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    r[a-1]+=1
    r[b-1]+=1
for i in range(n):
    print(r[i])

Submission status: Accepted

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

Submission status: Accepted

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

import collections
l_c=collections.Counter(l)


for i in range(N):
	print(l_c[i+1])

Submission status: Accepted

Solution code:
a,b = map(int,input().split(" "))
ar = [0 for i in range(a)]
for j in range(b):
    l,m = map(int,input().split(" "))
    ar[l-1] += 1
    ar[m-1] += 1
for r in ar:
    print(r)

Submission status: Accepted

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

for _ in range(m):
  a, b = [int(s) - 1 for s in input().split()]
  x[a] += 1
  x[b] += 1

for i in x:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

ab = []
for _ in range(m):
    x = map(int, input().split())
    ab.extend(x)
for i in range(1, n+1):
    print(ab.count(i))

Submission status: Accepted

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

toshicount = collections.Counter(toshi)
for i in range(N):
    print(toshicount[i+1])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
list_ = []
for i in range(m):
    a,b = map(int,input().split())
    list_.append(a)
    list_.append(b)
cnt = 0
for j in range(1,n+1):
    print(list_.count(j))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
c=[0]*(n+1)
for i in range(0,m):
  a,b = map(int, input().split())
  c[a]=c[a]+1
  c[b]=c[b]+1
for i in range(1,n+1):
  print(c[i])

Submission status: Accepted

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[i])

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> int:
    n = next_int()
    m = next_int()
    dic = [0] * n

    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())

        dic[a] += 1
        dic[b] += 1

    [print(v) for v in dic]

    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> int:
    n = next_int()
    m = next_int()
    dic = [0] * n

    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())

        dic[a] += 1
        dic[b] += 1

    for i in range(n):
        print(dic[i])

    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> int:
    n = next_int()
    m = next_int()
    dic = dict()

    for i in range(1, n + 1):
        dic[i] = 0

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

        dic[a] += 1
        dic[b] += 1

    for i in range(1, n + 1):
        print(dic[i])

    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
city = [0]*(N+1) # not use idx 0
for _ in range(M):
    a,b = map(int, input().split())
    city[a] += 1
    city[b] += 1
for c in city[1:]:
    print(c)

Submission status: Accepted

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

for i in C:
    print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from itertools import chain
N, M = map(int, input().split())
a_list = []
for i in range(M):
  a_list.append(input().split())
a_list = list(chain.from_iterable(a_list))
for i in range(1, N + 1):
  print(a_list.count(str(i)))

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
edges = Counter(int(u) for _ in range(M) for u in input().split())
for i in range(1, N + 1):
    print(edges[i])

Submission status: Accepted

Solution code:
import sys

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

roads_count = [0 for i in range(n)]
for a_i, b_i in ab:
    if a_i != b_i:
        roads_count[a_i-1] += 1
        roads_count[b_i-1] += 1
[print(num) for num in roads_count]

Submission status: Accepted

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 ans:
    print(i)

Submission status: Accepted

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

list = []
for i in range(m):
	line = map(int, input().split())
	for l in line:
		list.append(l)

list.sort()

for i in range(1,n+1):
	cnt = 0
	for elem in list:
		if i == elem:
			cnt += 1
	print(cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = []
for i in range(m):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
for i in range(n):
  print(a.count(i+1))

Submission status: Accepted

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

a = []
b = []

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

ans = 0

for i in range(n):
    ans += a.count(i + 1)
    ans += b.count(i + 1)

    print(ans)
    ans = 0

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
list_prob = []
for i in range(0,m):
    list_prob += list(map(int, input().split()))
for i in range(1,n+1):
    print(list_prob.count(i))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map( int, input().split())
V = [ [] for _ in range(N)]
for _ in range(M):
    a, b = map( int, input().split())
    V[a-1].append(b-1)
    V[b-1].append(a-1)
for i in range(N):
    print( len(V[i]))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
S=[list(map(int,input().split())) for i in range(M)]
c=[0]*N
for i in range(M):
    for j in range(2):
        c[S[i][j]-1]+=1
for i  in range(N):
    print(c[i])