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

l = [0] * N

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

    l[a] += 1
    l[b] += 1

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

Solution (Python):
[n,m] = [int(i) for i in input().split()]
ab = []
dic = {}
for i in range(m):
  ab.append([int(j) for j in input().split()])

for i in range(m):
  if ab[i][0] in dic.keys():
    dic[ab[i][0]] += 1
  else:
    dic[ab[i][0]] = 1
    
  if  ab[i][1] in dic.keys():
    dic[ab[i][1]] += 1
  else:
    dic[ab[i][1]] = 1
    
for i in range(n):
  if i+1 in dic.keys():
    print(dic[i+1])
  else:
    print(0)

Solution (Python):
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
for s in range(m):
  a,b=map(int,input().split())
  d[a].append(b)
  d[b].append(a)
for s in range(1,n+1):
  print(len(d[s]))

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

Solution (Python):
from collections import defaultdict
N,M = map(int,input().split())
route = defaultdict(int)
for i in range(M):
    a,b = map(int,input().split())
    route[a] += 1
    route[b] += 1
for i in range(N):
    print(route[i+1])

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

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

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 c in cnt:
  print(c)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n,m=(int(i) for i in input().split())

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):




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

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

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

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

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

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 r in road:
    print(r)

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

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

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

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

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

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

for a in count:
    print(a)

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

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

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

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

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]=L[a-1]+1
    L[b-1]=L[b-1]+1

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

Solution (Python):



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):



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__':
    
    solve1()

Solution (Python):



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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('\n'.join([str(i)for i in l]))

Solution (Python):

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

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

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)

import collections
l_c=collections.Counter(l)


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

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

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

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(1,N+1):
  print(l.count(i))

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

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

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

Solution (Python):


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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(n):
  print(a.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_)

ans = 0

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

    print(ans)
    ans = 0

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

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

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

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

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

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

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

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

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 i in range(1,N+1):
    ans = 0
    ans += A.count(i) + B.count(i)
    print(ans)