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 = [int(x) for x in input().split()]
lst = [[int(x) for x in input().split()] for i in range(M)]
dict = {}
for i in range(1, N + 1):
    dict[i] = 0
for i in lst:
    for j in i:
        dict[j] += 1
for i in dict.values():
    print(i)

Solution (Python):
wlist = []
city, road = map(int, input().split())
for i in range(road):
    wlist.append(list(map(int, input().split())))
dst = []
for i in range(city):
    count = 0
    for k in wlist:
        if i+1 in k:
            count += 1
    dst.append(count)
for d in dst:
    print(d)

Solution (Python):
m,n=map(int,input().split())
a=[[int(i) for i in input().split()] for l in range(n)]
l=[]
for x in range(1,m+1):
    c=0
    for y in a:
        if y[0]==x:c+=1
        if y[1]==x:c+=1
    l.append(c)
for x in l:
    print(x)

Solution (Python):




def main():
    N, M = map(int, input().split())
    result = [0] * N
    for _ in range(M):
        A, B = map(int, input().split())
        result[A - 1] += 1
        result[B - 1] += 1
    for m in result:
        print(m)


if __name__ == "__main__":
    main()

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

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):
n, m = map(int, input().split())
list = []
for x in range(n):
    list.append(0)
for y in range(m):
    a, b = map(int, input().split())
    list[a - 1] += 1
    list[b - 1] += 1
for id in range(n):
    print(list[id])

Solution (Python):
def cityroadcount(n , m , a):
    reans = []
    for i in range(1 , n + 1):
        count = 0
        for w in range(m):
            count += int(a[w].count(i))
        reans.append(count)

    return reans

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

    ans = cityroadcount(n , m , a)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()

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

for i in range(1, n+1):
    print(sum(c.count(str(i)) for c in connections))

Solution (Python):

import numpy as np
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for __ in range(M)]

ab = np.array(ab).flatten()
for i in range(1,N+1):
    print(len(np.where(ab == i)[0]))

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):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]


MPs = {}

for a, b in ABs:
    a = int(a)  
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1

for mp in range(1, N+1):
    if mp not in MPs:
        print(0)
    else:
        print(MPs[mp])

Solution (Python):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
    a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for _, y in sorted(MPs.items()):
    print(y)

Solution (Python):
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
    a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for _, y in sorted(MPs.items()):
    print(y)

Solution (Python):
N, M = tuple(map(int, input().split()))
cnt = [0 for _ in range(N+1)]
for _ in range(M):
    fr, to = tuple(map(int, input().split()))
    cnt[fr] += 1
    cnt[to] += 1
for i in range(1, N+1):
    print(cnt[i])

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

for i in range(m):
  ori, dst = map(int, input().split())
  load[ori-1][dst-1] += 1
  load[dst-1][ori-1] += 1

for j in range(n):
  print(sum(load[j]))

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

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

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

Solution (Python):
from collections import Counter
n, m = map(int, input().split())
roads = [tuple(map(int, input().split())) for _ in range(m)]

roadss = ()
for road in roads:
  roadss += road

cr = Counter(roadss)
for i in range(1, n+1):
  print(cr[i])

Solution (Python):
N, M = map(int, input().split())
a, b = [0]*M, [0]*M
for i in range(M):
    tmp_a, tmp_b = map(int, input().split())
    a[i], b[i] = tmp_a, tmp_b
ab = zip(a,b)


num = [0]*(N+1)

for a_i, b_i in ab:
    num[a_i] += 1
    num[b_i] += 1

for i in range(len(num)):
    if i==0:
        continue
    else:
        print(num[i])

Solution (Python):
n, m = map(int, input().split())
dic = {}
for i in range(n):
	dic[i+1] = 0
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,j in sorted(dic.items()):
	print (j)

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

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

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 j in range(n):
	print(cnt[j])

Solution (Python):
n,m=map(int,input().split())
l=[0 for i in range(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):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

ans = []
for i in range(1, N+1):
    count = 0
    for j in range(M):
        if i in AB[j]:
             count += 1
    print(count)

Solution (Python):
import math
import sys


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




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

num = [int(i+1) for i in range(n)]
count = [0]*n

for i in range(m):
  for ii in range(n):
    if(a[i] == num[ii]):
      count[ii] = count[ii] + 1
    if(b[i] == num[ii]):
      count[ii] = count[ii] + 1

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

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

for d in D:
  print(d)

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

Solution (Python):
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

for i in L:
    print(i)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()
L = [LIST() for i in range(m)]

R = [[0] * n for i in range(n)]

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

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

Solution (Python):
tmp = input().split()
n = int(tmp[0])
m = int(tmp[1])

a = [0] * m
b = [0] * m

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

arr = [[0] * (n+1) for i in range(n+1)]

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

for i in range(1,n+1):
    count = 0
    for k in range(len(arr[i])):
        if arr[i][k] != 0:
            count += arr[i][k]
    print(count)

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):
    ans = 0
    for k in range(m):
        if (A[k] == i+1) or (B[k] == i+1):
            ans += 1
    print(ans)

Solution (Python):
from collections import defaultdict

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

dic = defaultdict(list)

for a, b in ab:
  dic[a-1].append(b-1)
  dic[b-1].append(a-1)

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

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

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

res = [0] *  N

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

for r in res:
    print(r)

Solution (Python):
N, M = map(int, input().split())
cities = {i: 0 for i in range(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])

Solution (Python):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
cnt = [0]*n

for k in range(n):
    for i in range(m):
        for j in range(2):
            if(k+1 == a[i][j]):
                cnt[k] += 1
for l in range(len(cnt)):
    print(cnt[l])

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

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

town_road = [0 for _ in range(N+2)]

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

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

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

a = []
b = []

for _ in range(m):
    aa,bb = input().split()    
    a.append(aa)
    b.append(bb)

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    road=[]
    for i in range(m):
        a,b=INTM()
        road.append(a)
        road.append(b)
    for i in range(n):
        ct=road.count(i+1)
        print(ct)
if __name__ == '__main__':
    do()

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

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

ans = []
for n in range(1, N+1):
    count = 0
    for i in range(M):
        for j in range(2):
            if ab[i][j] == n:
                count += 1
    ans.append(count)


for a in ans:
    print(a)

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

m_a = []
m_b = []
for i in range(m):
  m_a_tmp, m_b_tmp = map(int, input().split())
  m_a.append(m_a_tmp)
  m_b.append(m_b_tmp)

n_n = [0 for i in range(n)]

for a,b in zip(m_a, m_b):
  n_n[a-1] += 1
  n_n[b-1] += 1

for n in n_n:
  print(n)

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

import collections
c = collections.Counter(l)

for k, v in c.items():
    ans[k-1]+=v

for i in ans:
    print(i)

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

for i in range(1,n+1):
  print(ab.count(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
N,M = [int(i) for i in input().split()]
nes = [0] * (N+1)
for i in range(M) :
    a,b = [int(j) for j in input().split()]
    nes[a] +=1
    nes[b] +=1
for i in range(1,N+1) :
    print(nes[i])

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

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



print(*ans[1:], sep='\n')

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

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

road = []
for _ in range(N):
  road.append(0)

for i in range(M):
   a = ab[i][0]
   b = ab[i][1]
   road[a - 1] += 1
   road[b - 1] += 1

for j in road:
  print(j)

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

nm = a+b

ans = [0 for i in range(N)]
for j in range(0,(len(nm))):
    i = nm[j]
    ans[i-1] += 1

for i in range(0,len(ans)):
    print(ans[i])

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

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

city = dict()

for i in range(n):
  city[i + 1] = 0
  
for i in range(m):
  s, e = list(map(int, input().split()))
  city[s] += 1
  city[e] += 1

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

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 range(N):
    print(city[i])

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

for i in ans:
  print(i)

Solution (Python):


N, M = map(int, input().split())
road_list = []

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

for _ in range(1, N+1):
    print(road_list.count(_))

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

Solution (Python):
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
import collections 
d=collections.defaultdict(int)
for x,y in a:
    d[x]+=1
    d[y]+=1
for i in range(n):
    print(d[i+1])

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




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

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

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

for ans in town:
    print(ans)

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

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

result = 0
for i in range(1,n+1):
  for j in cList:
    result += j.count(i)
  print(result)
  result = 0

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

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


roadsCntArray = []

for i in range(N):
    roadsCntArray.append(AB.count(i+1))
    print(roadsCntArray[i])

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

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


roadsCntArray = []

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

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

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
city_road_nums = defaultdict(int)

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

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

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

bucket = [ 0 for _ in range(N)]

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

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

Solution (Python):

import collections as col
n,m=map(int, input().split())
l=[]
for i in range(m):
  x,y=map(int, input().split())
  l.extend([x,y])

d=col.defaultdict(int, col.Counter(l))

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

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

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

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

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

for x in range(N):
  y = x + 1
  ans = 0
  for index, s in enumerate(li):
    if y == s[0]:
      ans += 1
    
    if y == s[1]:
      ans += 1
  
  print(ans)

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

Solution (Python):
N,M = map(int,input().split())
edge = []
node = [[]for i in range(N)]
for i in range(M):
    n = list(map(int,input().split()))
    n[0] -= 1
    n[1] -= 1
    node[n[0]].append(n[1])
    node[n[1]].append(n[0])
    edge.append(n)
for i in node:
    print(len(i))

Solution (Python):


import numpy as np
import fractions as fra



n,m=map(int,input().split())
a=np.array([0]*(n+1))

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


print(*a[1:],sep="\n")

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

for i in range(m):
  x=[int(j) for j in input().split()]
  road.extend(x)
for k in range(1,n+1):
  print(road.count(k))

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
G = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = [int(x) for x in input().split()]
    G[a].append(b)
    G[b].append(a)
for i in range(1, (N + 1)):
    print(len(G[i]))

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

road = []
for i in range(m):
   tmp = [int(x) for x in input().split()]
   road.extend(tmp)

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

Solution (Python):

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

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

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

ans =[ab.count(i) for i in range(1, n+1)]

for i in ans:
    print(i)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,m=MI()
    deg=[0]*n
    for _ in range(m):
        a,b=MI1()
        deg[a]+=1
        deg[b]+=1
    for d in deg:
        print(d)

main()

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

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

Solution (Python):
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 r in R: print(r)

Solution (Python):
import sys


def solve(inp):
    (N, M) = map(int, inp.readline().split(' '))
    AB = [list(map(int, inp.readline().split(' '))) for i in range(M)]

    roads = [0 for i in range(N)]
    for ab in AB:
        roads[ab[0] - 1] += 1
        roads[ab[1] - 1] += 1

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

    return ""


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Solution (Python):


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

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


for i in range(1, n+1):

    count = 0
    for j in range(m):

        if i in ab[j]:
            count += 1
    print(count)

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

ans = dict()
for i in range(1, N+1):
    ans[i] = 0

for i in range(M):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += 1
    if b in ans:
        ans[b] += 1
        
ans = sorted(ans.items(), key=lambda x:x[0])
for k, v in ans:
    print(v)

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

for i in range(1,n+1):
    cnt = 0
    for j in range(m):
        cnt += x[j].count(i)
    lst.append(cnt)

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

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

for _ in range(N):
    V.append(0)

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

for node in range(N):
    print(V[node])

Solution (Python):
listanm = []

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

for x in range(n):
    listanm.append(0)

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

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

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

Solution (Python):
n, m = map(int, input().split())
deg = [0] * n
for i in range(m):
    u, v = map(int, input().split())
    deg[u - 1] += 1
    deg[v - 1] += 1
for i in range(n):
    print(deg[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
for i in range(n):
  print(l[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
for i in range(N):
    print(L[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 ans:
    print(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
print(*ans, sep="\n")

Solution (Python):
from collections import Counter
n,m=map(int,input().split())
L=[0]*(2*m)
for i in range(m):
    L[2*i],L[2*i+1]=map(int,input().split())
s=Counter(L)
for i in range(n):
    print(s[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 i in range(n):
    print(l.count(i+1))

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

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

for i in range(1, N+1):
  print(len(graph[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 j in range(n):
  print(a.count(j+1)+b.count(j+1))

Solution (Python):
from collections import Counter
def get(S):
    return list(map(S, input().split()))

N, M = get(int)
roads = Counter()

for i in range(M):
    a, b = get(int)
    roads[a] += 1
    roads[b] += 1

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

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

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

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

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

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

Solution (Python):
n, m = map(int, input().split())
Adj_dict = {}
for i in range(n):
    new = {i: []}
    Adj_dict.update(new)
for _ in range(m):
    a, b = map(int, input().split())
    Adj_dict[a-1].append(b-1)
    Adj_dict[b-1].append(a-1)


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

Solution (Python):
from collections import Counter
N, M = [int(i) for i in input().split()]
L = [list(map(int, input().split())) for i in range(M)]
LL = sum(L, [])

cou = Counter(LL)

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

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


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






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

for val in res.values():
    print(val)

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

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

for x, y in roads:
    res[x] += 1
    res[y] += 1

for val in res.values():
    print(val)

Solution (Python):
n,m = map(int,input().split())
from collections import defaultdict
dic = defaultdict(int)

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

Solution (Python):
import sys
n,m = map(int, sys.stdin.readline().split())

l = [0] * n

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

for i in l:
    print(i)

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

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

for i in range(1, N + 1):
    count = 0
    for j in range(M):
        if A[j] == i or B[j] == i:
            count += 1
    print(count)

Solution (Python):
import sys
from collections import Counter

n, m, *r = map(int, sys.stdin.read().split())

def main():
    c = Counter(r)
    for v in range(1, n+1):
        yield c.get(v, 0)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

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

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
print(*L[1:],sep='\n')

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

Solution (Python):
import sys
bbn=1000000007
	

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

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n,m = [int(i) for i in input().split()]
graph = [0 for _ in range(n)]

for i in range(m):
    ai,bi = [int(i) for i in input().split()]
    graph[ai-1] += 1
    graph[bi-1] += 1
    
for i in range(n):
    print(graph[i])

Solution (Python):
n,m = map(int, input().split())
load_info = {i:[] for i in range(1, n+1)}

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

for n_i in range(1, n+1):
  print(len(load_info[n_i]))

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

l = []
for m in range(M):
    l += input().split()

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

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