Problem:


Score : 200 points

Problem Statement

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

Constraints

2≤N,M≤50

1≤a_i,b_i≤N

a_i ≠ b_i

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N M
a_1 b_1
:  
a_M b_M

Output

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

Sample Input 1

4 3
1 2
2 3
1 4

Sample Output 1

2
2
1
1

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

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

City 3 is connected to the 2-nd road.

City 4 is connected to the 3-rd road.

Sample Input 2

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

Sample Output 2

5
5

Sample Input 3

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

Sample Output 3

3
3
2
2
2
1
1
2



Sample input:
4 3
1 2
2 3
1 4


Sample output:
2
2
1
1

Submission status: Accepted

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

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 road in ab:
  ans[road[0] - 1] += 1
  ans[road[1] - 1] += 1
  
for a in ans:
  print(a, end='\n')

Submission status: Accepted

Solution code:
n, m = [int(num) for num in input().split(" ")]
list_road = []
for i in range(m):
  list_road += [int(num) for num in input().split()]

import collections as cl
dic = cl.Counter(list_road)
for i in range(1, n+1):
  print(dic[i])

Submission status: Accepted

Solution code:
# ABC061b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = [0] * n

for r in a:
    ans[r[0]-1] += 1
    ans[r[1]-1] += 1

for a in ans:
    print(a)

Submission status: Accepted

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

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

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

# output
for i in range(N):
    print(ans[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:
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n,m= map(int, sys.stdin.readline().split())
    a=[]
    for i in range(m):
        a += list(map(int, sys.stdin.readline().split()))
    for i in range(n):
        print(a.count(i+1))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for _ 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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = []
B = []
for i in range(m):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
for j in range(1,n+1):
  print(A.count(j)+B.count(j),end='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ret = [[] for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    ret[a] += [b]
    ret[b] += [a]
for i in range(1, n + 1):
    print(len(ret[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,sep='\n')

Submission status: Accepted

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

Submission status: Accepted

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

#全ての要素をn個分初期化
road = [0] * n

#全ての道路について調べる
for i in range(m):
  a,b = map(int,input().split())
  road[a-1] += 1
  road[b-1] += 1
  
for x in range(n):
  print(road[x])

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    d = dict()
    for _ in range(M):
        a, b = map(int, input().split())
        d[a] = d.get(a, 0) + 1
        d[b] = d.get(b, 0) + 1

    for a in range(1, N+1):
        if a in d:
            print(d[a])
        else:
            print(0)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int, input().strip().split(' '))
G = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().strip().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:
from collections import defaultdict
n,m=map(int,input().split())
graph = defaultdict(list)
for i in range(m):
  a,b=map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

for i in range(0,n):
  if i not in graph:
    print(0)
  else:
    print(len(graph[i]))

Submission status: Accepted

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

cities, roads = map(int, input().split())
connections = []
for i in range(roads):
    x, y = map(int, input().split())
    connections.append((x, y))

road_count = {}
for i in range(cities):
    road_count[i] = 0

for (x, y) in connections:
    # print("{}, {}".format(x, y))
    road_count[x - 1] += 1
    road_count[y - 1] += 1

# print(road_count)

for i in road_count.values():
    print(i)

Submission status: Accepted

Solution code:
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
bucket = [0 for _ in range(N)]
for i in range(M):
    a, b = map(int, sys.stdin.readline().rstrip().split())
    bucket[a-1] += 1
    bucket[b-1] += 1
for n in bucket:
    print(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 v in ans:
    print(v)

Submission status: Accepted

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

Submission status: Accepted

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

for c in city2city:
    print(c)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for i in range(1,N+1):
  counter = 0
  for j in range(M):
    if i in roads[j]:
      counter += 1
  ans.append(counter)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nm = input().split()
n = int(nm[0])
m = int(nm[1])
a = []
b = []
for i in range(m):
	ab = input().split()
	a.append(int(ab[0]))
	b.append(int(ab[1]))


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

Submission status: Accepted

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

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

Submission status: Accepted

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

c=[flatten for inner in road for flatten in inner]

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = []
  ans[sta].append(gol)
  
  if gol not in ans:
    ans[gol] = []
  ans[gol].append(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
ret = [0] * N

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
D = defaultdict(list)
for i in range(M):
  a, b = map(int, input().split())
  D[a-1].append(b-1)
  D[b-1].append(a-1)

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

Submission status: Accepted

Solution code:
# ABC061B - Counting Roads
def main():
    N, M = tuple(map(int, input().split()))
    E = tuple(tuple(map(int, input().split())) for _ in range(M))
    G = [[] for _ in range(N + 1)]
    for v, u in E:
        G[v] += [u]
        G[u] += [v]
    print(*(len(g) for g in G[1:]), sep="\n")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
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())
ans=[0 for i in range(n)]
for i in range(m):
    ans[a[i]-1]+=1
    ans[b[i]-1]+=1

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

Submission status: Accepted

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

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

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

for a in A:
    print(a)

Submission status: Accepted

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

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

for n in range(N):
  print(hist[n])

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = {i+1:0 for i in range(N)}
for i in range(M):
  x, y = map(int, input().split())
  ans[x] += 1
  ans[y] += 1

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

Submission status: Accepted

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

for i in road:
    print(len(i))

Submission status: Accepted

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

Submission status: Accepted

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

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

for edge in edges:
    print(len(edge))

Submission status: Accepted

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

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 li:
    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:
cities , num = map(int,input().split())
ary = [0 for i in range(num)]
result = [0 for i in range(cities)]
check = 0

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

for i in range(num):
    check = ary[i][0]
    result[check-1] += 1
    check = ary[i][1]
    result[check-1] += 1

for i in range(cities):
    print(result[i])

Submission status: Accepted

Solution code:
(nodes, roads) = (int(tok) for tok in input().split())

count = { i : 0 for i in range(1, nodes + 1) }
for _ in range(roads):
    for tok in input().split():
        count[int(tok)] += 1

for i in range(1, nodes + 1):
    print(count[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append(a)
    ab.append(b)
ab_cnt = Counter(ab)
for i in range(n):
    print(ab_cnt[i+1])

Submission status: Accepted

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

num_road = [0] * N

for a, b in ab_list:
  num_road[a-1] += 1
  num_road[b-1] += 1

for item in num_road:
  print(item)

Submission status: Accepted

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

Submission status: Accepted

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

ans=[]

for i in range(m) :
  temp=li[i]
  ans.append(temp[0])
  ans.append(temp[1])
for i in range(n) :
  print(ans.count(i+1))

Submission status: Accepted

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

for i in num:
  print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    ans = [0]*N
    for aa, bb in zip(a, b):
        ans[aa-1] += 1
        ans[bb-1] += 1
    print(*ans, sep="\n")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for j in range(N):
  print(L[j])

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())
k = [0]*N
for _ in range(M):
	a, b = map(int, input().split())
	k[a-1] += 1
	k[b-1] += 1

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

Submission status: Accepted

Solution code:
import numpy as np

N,M=(int(x) for x in input().split())
c=np.zeros(50)
for i in range(M):
    a,b=(int(x) for x in input().split())
    c[a-1]=c[a-1]+1
    c[b-1]=c[b-1]+1
for i in range(N):
    print(int(c[i]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

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

for i in x:
    print(i)

Submission status: Accepted

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

for i in range(N):
    r = 0
    r += a.count(i+1)
    r += b.count(i+1)
    print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    ans = [0 for i in range(N)]
    
    for _ in range(M):
        a,b = inputMap()
        ans[a-1] += 1
        ans[b-1] += 1
        
    for i in ans:
        print(i)
    
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

ans=[0]*n

total=[]

for i in range(m):
    c=sorted(list(map(int,input().split())))
    ans[c[0]-1]+=1
    ans[c[1]-1]+=1
    total.append(c)

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

Submission status: Accepted

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

for j in range(n):
  print(a[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M,*roads = map(int,open(0).read().split())
for i in range(1,N+1):print(roads.count(i))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

N, M = [int(v) for v in input().split()]
c = Counter()
for _ in range(M):
    a, b = [v for v in input().split()]
    c[a] += 1
    c[b] += 1
for i in range(N):
    print(c[str(i + 1)])

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
t=[]
for i in range(M):
    t.append(list(map(int,input().split())))
for i in range(1,N+1):
    a=0
    for j in range(M):
        if i in t[j]:
            a+=1
    print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict


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

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

for k in range(1, n+1):
    print(route_dict[k])

Submission status: Accepted

Solution code:
import numpy as np

ncity, nlines = map(int, input().rstrip("\n").split())
matrix = np.zeros((ncity, ncity), dtype=int)
for _ in range(nlines):
    l, c = map(lambda x: int(x) - 1, input().rstrip("\n").split())
    matrix[l][c] += 1
    matrix[c][l] += 1

for list_ in matrix:
    print(sum(list_))

Submission status: Accepted

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

for i in range(len(ab)):
    ab_plane.append(ab[i][0])
    ab_plane.append(ab[i][1])

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

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

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

    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=[0]*n
for i 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())
li = [0]*n
for i in range(m):
    a,b = map(int, input().split())
    li[a-1]+=1
    li[b-1]+=1
for j in range(n):
    print(li[j])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = dict.fromkeys([str(i) for i in range(1,n+1)], 0)
li = [list(map(int, input().split())) for j in range(m)]
for i in range(m):
    ans[str(li[i][0])] += 1
    ans[str(li[i][1])] += 1
for k in range(1,n+1):
    print(ans[str(k)])

Submission status: Accepted

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

aLst = [0] * M
bLst = [0] * M

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

for i in range(1, N + 1):
    ans = aLst.count(i)
    ans += bLst.count(i)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
 #ABC 61, B - counting roads
from collections import Counter
n, m = [int(el) for el in input().split(' ')]
C = Counter()
for i in range(m):
    C.update([int(el) for el in input().split(' ')])
for i in range(n):
    print(C[i+1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = list(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
n_road = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
	n_road[(al[i]-1)][(bl[i]-1)] += 1
	n_road[(bl[i]-1)][(al[i]-1)] += 1
for i in range(n):
	print(sum(n_road[i]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
R = []
for i in range(M):
  a = list(map(int,input().split()))
  b = a[0]
  c = a[1]
  R.append(b)
  R.append(c)
  
for l in range(1,N+1):
  ans = []
  ans = [i for i in R if i == l ]
  print(len(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    G = [[] for _ in range(N)]
    for i in range(M):
        G[a[i]-1].append(b[i]-1)
        G[b[i]-1].append(a[i]-1)
    for i in range(N):
        print(len(G[i]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(M):
    ca,cb=map(int,input().split())
    count[ca-1] +=1
    count[cb-1] +=1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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