Problem:


Score : 200 points

Problem Statement

There are N cities and M roads.
The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.
There may be more than one road that connects the same pair of two cities.
For each city, how many roads are connected to the city?

Constraints

2≤N,M≤50

1≤a_i,b_i≤N

a_i ≠ b_i

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N M
a_1 b_1
:  
a_M b_M

Output

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

Sample Input 1

4 3
1 2
2 3
1 4

Sample Output 1

2
2
1
1

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

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

City 3 is connected to the 2-nd road.

City 4 is connected to the 3-rd road.

Sample Input 2

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

Sample Output 2

5
5

Sample Input 3

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

Sample Output 3

3
3
2
2
2
1
1
2



Sample input:
4 3
1 2
2 3
1 4


Sample output:
2
2
1
1

Submission status: Accepted

Solution code:
(N, _), *edges = [map(int, s.split()) for s in open(0)]
graph = {i: [] for i in range(N)}
for a, b in edges:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
print("\n".join(str(len(graph[i])) for i in range(N)))

Submission status: Accepted

Solution code:
(N, _), *edges = [list(map(int, s.split())) for s in open(0)]
graph = {i: [] for i in range(N)}
for a, b in edges:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
print("\n".join(str(len(graph[i])) for i in range(N)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
X = [0]*N
for _ 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])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

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

for x in range(1, N + 1):
    print(ab.count(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
road = [input().split() for i in range(M)]
for i in range(N):
    num = 0
    for l in range(M):
        num = num + road[l].count(str(i+1))
    print(num)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ab = [ list(map(int, input().split())) for _ in range(m) ]
import numpy as np
ans = np.array([ [0] * n ] * n)

for i in ab:
    ans[i[0]-1][i[1]-1] += 1
    ans[i[1]-1][i[0]-1] += 1
for  i in ans:
    print(sum(i))

Submission status: Accepted

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

n = argList[0]
m = argList[1]

citys = [0]*n

for i in range(m):
    arg = list(map(int, input().split())) 
    citys[arg[0]-1] +=1 
    citys[arg[1]-1] +=1 

for c in citys:
    print(c)

Submission status: Accepted

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

l = [0]*n

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

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

Submission status: Accepted

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

ab = [0]*m

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

to = [0]*n
d = [0]*2
for i in range(0,m):
  d[0] = int(ab[i][0])
  d[1] = int(ab[i][1])
  to[d[0]-1] += 1
  to[d[1]-1] += 1

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

Submission status: Accepted

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

ans = [[] for _ in range(n + 1)]
for a, b in ab:
    ans[a].append(b)
    ans[b].append(a)

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

Submission status: Accepted

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


city = [0]*N
for i in range(M):
    city[ab[i][0]-1] += 1
    city[ab[i][1]-1] += 1

for number in city:
    print(number)

Submission status: Accepted

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

for _ in range(m):
    for i in map(int, input().split()):
        l.append(i)

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

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

    mat[a - 1, b - 1] += 1
    mat[b - 1, a - 1] += 1


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split()))
from collections import defaultdict
d=defaultdict(list)
for _ in range(m):
    a,b = list(map(int, input().split()))
    d[a].append(b)
    d[b].append(a)
ans=[0]*n
for k in d:
    ans[k-1]=len(d[k])
print(*ans, sep='\n')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
l=list()
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))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
road = [list(map(int,input().split())) for r in range(m)]
ans = [0] * n
for r in road:
	for rr in r:
		ans[rr-1] += 1
for a in ans:
	print(a)

Submission status: Accepted

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

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

maps = [0 for _ in range(N+1)]

for road in roads:
    maps[road[0]] += 1
    maps[road[1]] += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
metro = {i:0 for i in range(N)}

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [0] * n
for i in x:
    ans[i[0]-1] += 1
    ans[i[1]-1] += 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
route = {i: 0 for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    route[a] += 1
    route[b] += 1
route = (x[1] for x in sorted(route.items(), key=lambda x: x[0]))
print(*route, sep='\n')

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,M = inputIL()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    edge=[[] for _ in range(N)]
    for i in range(M):
        a,b=map(int1,input().split())
        edge[a].append(b)
        edge[b].append(a)
    for i in range(N):
        print(len(edge[i]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

n,m = map(int,input().split())
s = [0] * n

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

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

Submission status: Accepted

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

import itertools

abb = list(itertools.chain.from_iterable(ab))

from collections import Counter
count = Counter(abb)
for i in range(1,n+1):
    print(count[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, m  = map(int, input().split())
#  = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for i in range(m)]
#
# c = collections.Counter()

doro = [0] * (n + 1)

for ab_ in ab:
    a, b = ab_
    doro[a] += 1
    doro[b] += 1

for d in doro[1:]:
    print(d)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

N, M = map(int, input().split())
D = {}
for i in range(1, N+1):
    D[i] = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

towns_road = defaultdict(list)
for a, b in ab_list:
    towns_road[a].append(b)
    towns_road[b].append(a)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 i in range(N):
    print(res[i])

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

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

[print(road_counts[k]) for k in road_counts]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [0]*n

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
m,n = map(int, input().split())
road_dict = {k+1:0 for k in range(m)}
for _ in range(n):
  i, j = map(int, input().split())
  road_dict[i] += 1
  road_dict[j] += 1
for v in road_dict.values():
  print(v)

Submission status: Accepted

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

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

for r in city:
    print (len(r))

Submission status: Accepted

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

for i in range(N):
    dict[str(i+1)] = 0
for i in range(M):
    ai, bi = input().split()
    dict[ai] += 1
    dict[bi] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

    cities = [0 for _ in range(n)]

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

        cities[a - 1] += 1
        cities[b - 1] += 1
    
    for bridges in cities:
        print(bridges)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for ans in table:
    print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def main():
    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 a in A:
        print(a)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

l = [0]*n

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

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

Submission status: Accepted

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

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

for j in ans:
    print(j)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

roads = [[] for _ in range(N)]

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

for i in roads:
    print(sum(i))

Submission status: Accepted

Solution code:
from collections import defaultdict

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

memo = [0]*N

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

print(*memo, sep="\n")

Submission status: Accepted

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

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

c = collections.Counter(sum(A,[]))

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

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)
for i in range(m):
    d[ab[i][0]] += 1
    d[ab[i][1]] += 1

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

Submission status: Accepted

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

road = [[0]*N for i in range(N)]

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = [0 for _ in range(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])

Submission status: Accepted

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

num = [0] * n

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

for x in range(0, n):
    print(num[x])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

road = [0] * n

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    ABs = [list(map(int, input().split())) for _ in range(m)]
    anss = [0]*n
    for AB in ABs:
        anss[AB[0]-1] += 1
        anss[AB[1]-1] += 1
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for ab in AB:
  ANS[ab[0] - 1] += 1
  ANS[ab[1] - 1] += 1

[print(ans) for ans in ANS]

Submission status: Accepted

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

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,M=pin()
    ans=[0]*N
    for i in range(M):
        a,b=pin()
        ans[a-1]+=1
        ans[b-1]+=1
    for an in ans:
        print(an)
#%%submit!
resolve()

Submission status: Accepted

Solution code:
N,M = list(map(int,input().split()))
L = [list(map(int,input().split())) for _ in range(M)]
LL = {}
for i in range(1,N+1):
    LL[i] = 0
for l in L:
    LL[l[0]] += 1
    LL[l[1]] += 1
for i in range(1,N+1):
    print(LL[i])

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
road = []
city = [0]*N
for i in range(M):
    road.append(list(map(int, input().split())))

for a, b in road:
    city[a - 1] += + 1
    city[b - 1] += + 1

for i in city:
    print(i)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(M)]
ab = [i for inner in ab for i in inner]

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

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
N, M = ri_()
d = [0] * N
for i in range(M):
    a, b = ri_()
    d[a - 1] += 1
    d[b - 1] += 1
for i in range(N):
    print(d[i])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
dic = defaultdict(lambda: 0)

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

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

Submission status: Accepted

Solution code:
import numpy as np
n, m = map(int, input().split())
road = [0]*n
a = [0]*m
a = np.array(a)
b = [0]*m
b = np.array(b)
for i in range(m):
  x, y = input().split()
  a[i] = (int(x))
  b[i] = (int(y))
for i in range(m):
  road[int(a[i]) - 1] += 1
  road[int(b[i]) - 1] += 1
for i in road:
    print(i)