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

Solution (Python):

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


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

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

Solution (Python):
n, m = map(int,input().split())
road = [list(map(int,input().split())) for _ in range(m)]
cnt = [0] * n
for i in road:
    cnt[i[0]-1] += 1
    cnt[i[1]-1] += 1
for j in range(n):
    print(cnt[j])

Solution (Python):
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
for i in l:
    print(i)

Solution (Python):
c, r = map(lambda x: int(x), input().split())
total = [0] * c
for i in range(r):
    f, s = map(lambda x: int(x), input().split())
    total[f - 1] += 1
    total[s - 1] += 1

for number in total:
    print(number)

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

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

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

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

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

Solution (Python):
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)
for j in range(n):
    print(A.count(j+1)+B.count(j+1))

Solution (Python):
N,M=map(int,input().split())
x=[0]*(N+1)
for i in range(M) :
  a,b=map(int,input().split())
  for j in range(1,N+1) :
    if a==j or b==j :
      x[j]+=1
for i in range(1,N+1) :
  print(x[i])

Solution (Python):
from collections import defaultdict
n,m = map(int, input().split())
ans = 0
route = [[0]*(n+1) for i in range(n+1)]

for i in range(m):
  f,t = map(int, input().split())
  route[f][t] += 1
  route[t][f] += 1

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

Solution (Python):
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 range(n):
    print(ans[i])

Solution (Python):
from typing import List


def answer(n: int, m: int, ab_s: List[List[int]]) -> List[int]:
    roads = [0 for _ in range(n)]
    for ab in ab_s:
        a, b = ab
        roads[a - 1] += 1
        roads[b - 1] += 1

    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()

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

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

graph = [[] for i in range(n+1)]

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

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

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    for _ in range(m):
        a, b = i_map()
        num_list.append(a)
        num_list.append(b)

    num_counter = Counter(num_list)

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


if __name__ == '__main__':
    main()

Solution (Python):
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]))

Solution (Python):
N,M = map(int,input().split())
L = [0] * (N+1)
for i in range(M):
  A,B = map(int,input().split())
  L[A] += 1
  L[B] += 1
for j in range(1,N+1):
  print(L[j])

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

Solution (Python):
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(*L, sep = "\n")

Solution (Python):
N,M=map(int,input().split())
city=[0]*N
for i in range(M):
  road=list(map(int,input().split()))
  for j in road:
    city[j-1]+=1
for i in city:
  print(i)

Solution (Python):
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])

Solution (Python):

import sys
input=sys.stdin.readline

def main2():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp=[0]*n
    for number in numbers:
        for n in number:
            dp[n-1]+=1
    for ans in dp:
        print(ans)

def main():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp={}
    for number in numbers:
        for n in number:
            if n not in dp:
                dp[n]=1
            else:
                dp[n]+=1
    print(dp)
    for i in range(1,len(dp)+1):
        print(dp[i])

if __name__=="__main__":
    main2()

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

Solution (Python):
N, M = map(int, input().split())
data = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    data[x].append(y)
    data[y].append(x)

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

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

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

Solution (Python):
n,m=map(int,input().split())
D=dict()
for i in range(n):
  D[i+1]=0
for i in range(m):
  a,b=map(int,input().split())
  D[a]+=1
  D[b]+=1
for i in range(1,n+1):
  print(D[i])

Solution (Python):
n,m = map(int,input().split())
data = [input().split() for i in range(m)]
for i in range(1,n+1):
    count = 0
    for j in range(m):
        if int(data[j][0]) == i or int(data[j][1]) == i:
            count += 1
    print(count)

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

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

Solution (Python):
m,n=[int(x) for x in input().split()]
connections=[[] for i in range(m+1)]
for i in range(n):
	a,b=[int(x) for x in input().split()]
	connections[a].append(b)
	connections[b].append(a)
for i in range(1,m+1):
	print(len(connections[i]))

Solution (Python):
n,m = map(int,input().split())
N = list(range(1,n+1))
D = dict.fromkeys(N,0)

for _ in range(m):
  R = list(map(int,input().split()))
  for r in R:
    D[r] += 1

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

Solution (Python):
n , m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
    cnt = 0
    for j in range(m):
        if ab[j][0] == i+1 or ab[j][1] == i+1:
            cnt += 1
    ans.append(cnt)
for k in range(n):
    print(ans[k])

Solution (Python):
import itertools

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

res = []

for i in range(M):
    ab = list(map(int, input().split()))
    res.append(ab)

res = list(itertools.chain.from_iterable(res))

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

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

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

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

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

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

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

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

Solution (Python):
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
ans = [0] * N

for i in range(M):
  ab = list(map(int,readline().split()))
  for a in ab:
    ans[a - 1] += 1
    
for a in ans:
  print(a)

Solution (Python):
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(n):
	t = i + 1
	ans = l.count(t)
	print(ans)

Solution (Python):
n, m = map(int, input().split())
AB = [[] for _ in range(n)]
for i in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    AB[a].append(b)
    AB[b].append(a)
for i in range(n):
    print(len(AB[i]))

Solution (Python):
N,M = map(int,input().split())
city = [0] * N

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

Solution (Python):
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(1,n+1):
    print(a.count(i))

Solution (Python):

def main():
    import collections


    n, m = map(int, input().split())
    cnt = []

    for _ in range(m):
        temp = list(input().split())
        cnt += temp
    else:
        ans = collections.Counter(cnt)
        for i in range(1, n+1):
            print(ans[str(i)])


if __name__ ==  "__main__":
    main()

Solution (Python):
N, M = map(int,input().split())
ab_list = []

for i in range(M):
    a, b = map(int,input().split())
    ab_list.append(a)
    ab_list.append(b)
    
for i in range(1, N + 1):
    print(ab_list.count(i))

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

for x in ans:
    print(x)

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

for v in graph[1:]:
    print(len(v))

Solution (Python):
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])

Solution (Python):

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b


for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans, adj
for adj in graph:
    ans.push_back(adj.size())

print(*ans, sep='\n')

'''

    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):


import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b


for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans
for i in range(N):
    ans.push_back(graph[i].size())

print(*ans, sep='\n')

'''
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):
mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b


for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans
for i in range(N):
    ans.push_back(graph[i].size())

print(*ans, sep='\n')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):
mycode = r'''





ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b


for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans, adj
for adj in graph:
    ans.push_back(adj.size())

print(*ans, sep='\n')

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):
import sys
import numpy as np
import collections as cl
import itertools as it

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000)

n, m = map(int, readline().split())
A = []
B = []
for _ in range(m):
    a, b = map(int, readline().split())
    A.append(a)
    B.append(b)
for i in range(n):
    print(A.count(i+1)+B.count(i+1))

Solution (Python):
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 n in range(1, N+1):
  print(L.count(n))

Solution (Python):
mycode = r'''





ctypedef long long LL

cdef extern int __builtin_popcount(unsigned int) nogil

import numpy as np

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline 


cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


cdef read_matrix(LL H,LL W):
    
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) 
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)


from libcpp.vector cimport vector as vec

cdef LL N,M
N,M=ints()
AB=read_matrix(M,2)-1
cdef LL a,b

ctypedef vec[vec[LL]] Graph
cdef Graph graph=Graph(N)

for a,b in AB:
    graph[a].push_back(b)
    graph[b].push_back(a)

cdef vec[int] ans
for i in range(N):
    ans.push_back(graph[i].size())
print(*ans, sep='\n')
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Solution (Python):
mycode = '''





ctypedef long long LL

cdef extern int __builtin_popcount(unsigned int) nogil

import numpy as np

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline 


cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


cdef read_matrix(LL H,LL W):
    
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) 
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)


from libcpp.vector cimport vector as vec

cdef LL N,M
N,M=ints()
AB=read_matrix(M,2)-1
cdef LL a,b

ctypedef vec[vec[LL]] Graph
cdef Graph graph=Graph(N)

for a,b in AB:
    graph[a].push_back(b)
    graph[b].push_back(a)

cdef vec[int] ans
for i in range(N):
    ans.push_back(graph[i].size())
print(*ans, sep='\\n')
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

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

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

Solution (Python):


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

for i in range(N):
    print(len(tree[i]))

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

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

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

Solution (Python):

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

Solution (Python):
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

print(*count, sep='\n')

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

Solution (Python):
n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
print("\n".join(list(map(lambda x:str(len(x)), edge))))

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [[] for _ in range(n)]
for _ in range(m):
    a, b = rm()
    a -= 1
    b -= 1
    li[a].append(b)
    li[b].append(a)
for lis in li:
    print(len(lis))

Solution (Python):
N,M=map(int,input().split())
cnt=[0 for i in range(N)]


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

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

Solution (Python):
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+b).count(i+1))

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    res = [0] * (N + 1)

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

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


if __name__ == '__main__':
    main()

Solution (Python):


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

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

Solution (Python):
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(i))

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

Solution (Python):
from collections import Counter

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

l=[]
for i in range(m):
  lis=list(map(int,input().split()))
  l+=lis
  
l=Counter(l)

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

Solution (Python):
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,n+1):
  print(al.count(i)+bl.count(i))

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

Solution (Python):
n,m=map(int,input().split())
a_s=[]
b_s=[]
for i in range(m):
  a,b=map(int,input().split())
  a_s.append(a)
  b_s.append(b)

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

Solution (Python):

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

A_B = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * N

for a, b in A_B:
    ans[a-1] += 1
    ans[b-1] += 1
for a in ans:
    print(a)

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

ab = [[] for _ in range(M)]
for i in range(len(ab)):
    ab[i] = list(map(int, input().split()))

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

for i in range(len(ab)):
    dict[ab[i][0]] += 1
    dict[ab[i][1]] += 1

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

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

Solution (Python):
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())

ans = [0] * n

for i in range(m):
    ans[a[i]-1] += 1
    ans [b[i]-1] += 1

for i in ans:
    print(i)

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

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

Solution (Python):
n,m = map(int, input().split())
g = [[] for _ in range(n)]

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

for i in cnt:
    print(i)

Solution (Python):
import numpy as np
n,m = map(int, input().split())
ans = np.zeros(n, dtype=int)
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])

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

ar = [0] * n

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

Solution (Python):
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

c = [[] for _ in range(n + 1)]

for a, b in edges:
    c[a].append(b)
    c[b].append(a)

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

Solution (Python):
def solve():
    N, M = [int(i) for i in input().split()]
    R = [[] for _ in range(N)]
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        R[a - 1].append(b)
        R[b - 1].append(a)
    for r in R:
        print(len(r))

if __name__ == "__main__":
    solve()

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

WAY = [0] * (N+1)
for a,b in AB:
  WAY[a] += 1
  WAY[b] += 1
  
print("\n".join(map(str,WAY[1:])))

Solution (Python):



def main():
    import numpy as np

    N, M = map(int, input().split())
    ab = np.array([list(map(int, input().split())) for _ in range(M)])
    for i in range(1, N+1):
        print(np.count_nonzero(ab == i))


main()

Solution (Python):
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 city:
    print(i)

Solution (Python):
N, M = map(int, input().split())
road_list = []
for i in range(M):
  road_list.append(list(map(int, input().split())))

road_dict = {}
for road in road_list:
  first_city = road[0]
  second_city = road[1]
  first_city_road_list = road_dict.get(first_city, [])
  first_city_road_list.append(second_city)
  road_dict[first_city] = first_city_road_list
  
  second_city_road_list = road_dict.get(second_city, [])
  second_city_road_list.append(first_city)
  road_dict[second_city] = second_city_road_list

for i in range(1, N+1):
  city_road_list = road_dict.get(i, [])
  road_num = len(city_road_list) if city_road_list != [] else 0
  print(road_num)

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

Solution (Python):
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(n):
    print(l.count(i+1))

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

for i in ans:
    print(i)

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

for i in roads:
    print(i)

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

for j in range(1,n+1):
    print(ans.count(j))

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,m = map(int, input().split())
    A = []
    B = []
    for _ in range(m):
        a,b = map(int, input().split())
        A.append(a)
        B.append(b)
    AB = []
    AB.extend(A)
    AB.extend(B)
    for i in range(n):
        count = 0
        for j in range(len(AB)):
            if i+1 == AB[j]:
                count += 1
        print(count)


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
c={i:0 for i in range(1,n+1)}
for _ in range(m):
  a,b=map(int,input().split())
  c[a]+=1;c[b]+=1
print(*c.values(),sep='\n')

Solution (Python):
n,m=map(int,input().split())
c={i:0 for i in range(1,n+1)}
for a,b in [list(map(int,input().split())) for i in range(m)]:
  c[a]+=1;c[b]+=1
print(*c.values(),sep='\n')

Solution (Python):
n, m = map(int, input().split())
s = []
N = [0 for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    s.append([a,b])
    N[a-1] += 1
    N[b-1] += 1
for j in range(n):
    print(N[j])

Solution (Python):
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(1, n + 1):
  print(a.count(i))

Solution (Python):
n, m = map(int, input().split())
l = [0]*(n+1)

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

for i in l[1:]:
    print(i)

Solution (Python):
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))

Solution (Python):
N,M=map(int,input().split())
ab=[]
for i in range(M):
    ab+=list(map(int,input().split()))
for i in range(1,N+1):
    print(ab.count(i))

Solution (Python):
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 range(n):
    print(ans[i])

Solution (Python):
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
    p,q=map(int,input().split())
    l[p-1]+=1
    l[q-1]+=1
print(*l,sep='\n')

Solution (Python):

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

Solution (Python):
def actual(N, M, A, B):
    AB = A + B

    counts = [AB.count(i) for i in range(1, N + 1)]
    
    return '\n'.join(map(str, counts))

N, M = map(int, input().split())
A, B = [], []
for _ in range(M):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
print(actual(N, M, A, B))

Solution (Python):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]
ans = [0 for _ in range(N)]
n = 1
while True:
    for i in range(M):
        for j in range(2):
            if n == ab[i][j]:
                ans[n-1] += 1
    if n == N:
        break
    n += 1
for i in range(N):
    print(ans[i])