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 = list(map(int,input().split()))
a = [list(map(int, input().split())) for i in range(m)]
ans = [0] * (n)

for i, j in a:
    ans[i-1] += 1
    ans[j-1] += 1

for ai in ans:
    print(ai)

Submission status: Accepted

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

Submission status: Accepted

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

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

for x in d:
    print(x)

Submission status: Accepted

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

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

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

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
for i in range(N):
    print(c[i+1])

Submission status: Accepted

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

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

for i in an:
    print(i)

Submission status: Accepted

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

#配列の定義
arr = [[0 for c in range(N)] for r in range(N)]

#配列へ入力
for i in range(M):
    a,b=input().split()
    a=int(a)
    b=int(b)
    #表の、aの列のbの行に1を追加
    arr[a-1][b-1]+=1
    #表の、bの列のaの行に1を追加
    arr[b-1][a-1]+=1

#取り出し
for i in range(N):
    print(sum(arr[i]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

a = [0] * M
b = [0] * M

ans = [0] * N

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

for i in range(N):
    k = 0
    l = 0
    for ii in range(M):
        if a[ii]==i+1:
            k += 1
        elif b[ii]==i+1:
            l += 1
    ans[i] = k + l

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a,b = map(int,input().split())

    list = [0]*a

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
roads = []
for i in range(M):
    roads.extend(list(map(int, input().split())))
for j in range(1, N+1):
    print(roads.count(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 range(n):
  print(ans[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 i in range(n):
  print(ans[i])

Submission status: Accepted

Solution code:
n,m = map(int,input().split(' '))
Result = [0]*n
i = 0
while i < m:
    a,b = map(int,input().split(' '))
    Result[a-1] += 1
    Result[b-1] += 1
    i += 1
ans = ''
for r in Result:
    ans += str(r) + '\n'
print(ans)

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
A = []
for i in range(M):
    A +=[int(x) for x in input().split()]

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

Submission status: Accepted

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

ans = [0]*n

for x, y in list_score:
    ans[x-1] += 1
    ans[y-1] += 1

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

Submission status: Accepted

Solution code:
town,sum_road=(int(x) for x in input().split())

al=[list() for x in range(town)]
for x in al:
  x.append(0)

for _ in range(sum_road):
  x,y=(int(x) for x in input().split())
  x-=1
  y-=1
  al[x][0]+=1
  al[y][0]+=1

for x in al:
  print(x[0])

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
cityroads=[list() for x in range(n)]
for a in range(m):
    s,t=map(int,input().split())
    cityroads[s-1].append(t-1)
    cityroads[t-1].append(s-1)
for b in cityroads:
    print(len(b))

Submission status: Accepted

Solution code:
n,m = map(int,input().rstrip().split(' '))
G = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().rstrip().split(' '))
  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())
a =[list(map(int,input().split())) for i in range(m)]
ans=[]
for i in range(m):
    for k in range(2):
        ans.append(a[i][k])
# print(ans)
import collections
ans=collections.Counter(ans)
# ans_sorted=sorted(ans.items(), key=lambda x:x[0])
# print(ans_sorted)
for i in range(1,n+1):
    print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[]
    for i in range(m):
        ai,bi=map(int,input().split())
        a.append(ai)
        a.append(bi)
    for i in range(1,n+1):
        icnt=0
        for nn in a:
            if nn==i:
                icnt=icnt+1
        print(icnt)

Submission status: Accepted

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

Submission status: Accepted

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

counters = {}

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

for i in ab:
    if i in counters:
        counters[i] += 1
    else:
        continue

for num in counters.values():
    print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
array = []
for i in range(m):
    array += 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())
ans = [0] * N
for _ in range(M):
  a, b = map(int, input().split())
  ans[a - 1] += 1
  ans[b - 1] += 1
print(*ans, sep="\n")

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

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

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 h in range(N):
    print(A[h])

Submission status: Accepted

Solution code:
def myAnswer(N:int,M:int,dic:dict)-> None:
   for i in dic.values():
      print(i)
   

def modelAnswer():
   tmp=1
def main():
   N,M = map(int,input().split())
   dic ={key:0 for key in range(1,N+1)}
   for _ in range(M):
      a,b = map(int,input().split())
      dic[a]+=1
      dic[b]+=1
   myAnswer(N,M,dic)

if __name__ == '__main__':
   main()

Submission status: Accepted

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

ans = defaultdict(int)

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 = map(int, input().split())
# 任意の値、要素数で初期化
l = [0] * N
for i in range(M):
    # 1 2 が入力されたらリストの 0と1 をインクリメントする
    a, b = [int(x) - 1 for x in input().split()]
    l[a] += 1
    l[b] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

"""
以下の指定では、一度の値変更で、全ての要素の該当部分の数値が一斉に変わる。
http://delta114514.hatenablog.jp/entry/2018/01/02/233002
n,m = map(int,input().split())
s = [[0]*n]*n
"""

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
E = {i: [] for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  # 0-indexed
    E[a].append(b)
    E[b].append(a)
for i in range(N):
    print(len(E[i]))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
path = {i+1: 0 for i in range(N)}

for i in range(M):
    ax, bx = map(int, input().split())
    path[ax] += 1
    path[bx] += 1

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

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

Submission status: Accepted

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

tot1=[]
tot2=[]


for _ in range(m):
    a,b = map(int,input().split())
    tot1.append(a)
    tot2.append(b)

for i in range(1,n+1):
    cnt=(tot1+tot2).count(i)
    print(cnt)

Submission status: Accepted

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

num = [0] * N
for j in range(N):
    for k in range(M):
        if str(j+1) == load[k][0] or str(j+1) == load[k][1]:
            num[j] += 1
    print(num[j])

Submission status: Accepted

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

Submission status: Accepted

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

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

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())
a, b = [0]*m, [0]*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))

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):
    cnt = 0
    for j in l:
        cnt += j.count(i)
    print(cnt)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import collections

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

c_A = collections.Counter(A)
c_B = collections.Counter(B)

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

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ans=[0]*n
for i in range(m):
  a,b = list(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:
# ABC 061: B – Counting Roads
n, m = map(int, input().split())
routes = []
for i in range(m):
    routes.extend([int(s) for s in input().split()])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
dict = {}
for x in range(N):
    dict[x + 1] = 0
for y in range(M):
    a, b = map(int, input().split())
    dict[a] += 1
    dict[b] += 1
for z in dict.values():
    print(z)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

G = [[] for _ in range(N + 1)]
for el in ab:
    a, b = el
    G[a].append(b)
    G[b].append(a)
#print(G)

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
l = [0]*n

for i in range(m):
    a,b = iim()
    l[a-1] += 1
    l[b-1] += 1
for j in l:
    print(j)

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
c = [0 for i 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 range(n):
    print(c[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in r:
    print(i)

Submission status: Accepted

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

for _ in range(m):
  c,r=map(int,input().split())
  
  a.append(c)
  b.append(r)
  
for i in range(n):
  ans=a.count(i+1)
  ans+=b.count(i+1)
  print(ans)

Submission status: Accepted

Solution code:
n,m=[int(i) for i in input().split()]
brinum=[0]*n
for i in range(m):
    one,two=[int(i) for i in input().split()]
    brinum[one-1]+=1
    brinum[two-1]+=1
for i in brinum:
    print(i)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = 0
#最後にNoneを消す。
roads_memo = [[None] for i in range(N)]

for _ in range(M):
    ai, bi = map(int, input().split())
    roads_memo[ai-1].append(bi)
    roads_memo[bi-1].append(ai)

for memo in roads_memo:
    del memo[0]
    print(len(memo))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x_l=[]
for i in range(m):
    x_l+= list(map(int,input().split()))
dic={}
for i in x_l:
    if i not in dic:
        dic[i]=1
    else:dic[i]+=1

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

Submission status: Accepted

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

for _ in range(m):
    l += input().split() 

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

Submission status: Accepted

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

for i in ab:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

cities = [0] * N

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

for load in cities:
  print(load)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# abc061_b.py

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

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

Submission status: Accepted

Solution code:

import math
import itertools
import statistics
#import numpy as np
import collections

#n = int(input())
n, m = list(map(int, input().split()))
a = []
b = []

for i in range(m):
    x,y = [int(j) for j in input().split()]
    a.append(x)
    b.append(y)



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

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


#print(road)

Submission status: Accepted

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

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

for i in ans:
    print(i)

Submission status: Accepted

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

city = [0]*n

for i in range(m):
  city[a[i][0]-1] += 1
  city[a[i][1]-1] += 1
  
print(*city, sep = '\n')

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
for i in ans[1:]:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
array = [[]for i in range(n)]

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

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

Submission status: Accepted

Solution code:
import numpy as np



N,M =[int(i) for i in input().split()]

a = np.ones(M)
b = np.ones(M)

for i in range(M):
    a[i],b[i] = [int(j) for j in input().split()]
    
ans = np.zeros(N)
    
for i in range(M):
    A = int(a[i]-1)
    B = int(b[i]-1)
    ans[A]+=1
    ans[B]+=1
    
for i in range(N):
    print(int(ans[i]))

Submission status: Accepted

Solution code:
import itertools
n,m=map(int,input().split())
ab= [list(map(int,input().split())) for _ in range(m)]
ab=list(itertools.chain.from_iterable(ab))
for i in range(1,n+1):
    print(ab.count(i))

Submission status: Accepted

Solution code:
import collections

n, m = map(int,input().split())
road = []
for _ in range(m):
    s = list(map(int,input().split()))
    road.append(s[0])
    road.append(s[1])

c = collections.Counter(road)
for i in range(1,n+1):
    print(c[i])

Submission status: Accepted

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

r=' '.join(r).split()
for i in range(1,n+1):
    print(r.count(str(i)))

Submission status: Accepted

Solution code:

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

city=[]
for i in range(n):
    city.append(0)

for aa in a:
    city[aa-1]=(city[aa-1]+1)

for bb in b:
    city[bb-1]=(city[bb-1]+1)

for cc in city:
    print(cc)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import collections
n, m = map(int,input().split())
ab = []
for i in range(m):
    ab.extend(list(map(int, input().split())))

c = collections.Counter(ab)
for i in range(1,n + 1):
    print(c[i])

Submission status: Accepted

Solution code:
data=input().rstrip().split()
n=int(data[0])
ans=[0 for i in range(n)]
m=int(data[1])

for i in range(m):
  data=input().rstrip().split()
  ans[int(data[0])-1]+=1
  ans[int(data[1])-1]+=1
for j in range(n):
	print(ans[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cities_count, roads_count = [int(x) for x in input().split(' ')]

cities_roads_count = [0] * cities_count

for i in range(roads_count):
    a, b = [int(x) for x in input().split(' ')]

    cities_roads_count[a - 1] += 1
    cities_roads_count[b - 1] += 1

for c_r in cities_roads_count:
    print(c_r)

Submission status: Accepted

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

city_list = [0]*n

def func(a,b):
    city_list[a-1] += 1
    city_list[b-1] += 1

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

    func(a,b)

for j in city_list:
    print(j)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc061/tasks/abc061_b

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

# 各都市から、どこの都市に道路が伸びているかという情報
graph_list = [[] for i in range(N)]

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


for i in range(N):
    print(len(graph_list[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 range(n):
    print(ans[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N, M = [int(i) for i in input().split()]

roads = []

for i in range(M):
    roads.extend(input().split())
    
c = Counter(roads)

for i in range(N):
    if str(i+1) in c.keys():
        print(c[str(i+1)])
    else :
        print('0')

Submission status: Accepted

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

n, m = MAP()
ab = []
for i in range(m):
    ab.extend(LIST())
for i in range(n):
    ans = ab.count(i + 1)
    print(ans)

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

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].append(b)
    d[b].append(a)
for g in range(1, n+1):
    print(len(d[g]))

Submission status: Accepted

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

Submission status: Accepted

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

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

for n in range(N):
  print(dic[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())
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):
    ans = L.count(j)
    print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC061.B
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 m in range(1,N+1):
    ans = L.count(m)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Mon Mar 23 19:34:20 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ab = nan(m)

g = [[] for _ in range(n)]
for i in range(m):
    a, b = ab[i]
    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())
T = [list(map(int, input().split())) for i in range(m)]

for i in range(n):
    ans = 0

    for j in range(m):
        ans = ans + T[j].count(i + 1)

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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