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

itr = 0
count = 0
d = {}
for j in list(range(1,N+1,1)):
    d[j] = 0

for k in a:
    d[k] = d[k] + 1

for o in list(range(1,N+1,1)):
    print(d[o])

Submission status: Accepted

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

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
print('\n'.join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
v = [map(int, raw_input().split()) for i in range(M)]
w = [0 for i in range(N)]
for a, b in v:
    w[a-1] += 1
    w[b-1] += 1
for i in range(N):
    print w[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 ans:
    print(i)

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

Submission status: Accepted

Solution code:
#ABC061B

n,m=map(int,raw_input().split())
l=[]
for i in xrange(m):
 a,b=map(int,raw_input().split())
 l.append(a)
 l.append(b)
for i in xrange(1,n+1):
 cnt=l.count(i)
 print cnt

Submission status: Accepted

Solution code:
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
    ith = input().split()
    hyou += ith
hyou = list(map(int,hyou))
j = 1
while j <= N:
    print(hyou.count(j))
    j += 1

Submission status: Accepted

Solution code:
import sys

def solve():
    N, M = map(int, input().split())

    deg = [0] * N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai, bi = ai - 1, bi - 1
        deg[ai] += 1
        deg[bi] += 1

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import numpy as np
N, K = map(int, raw_input().split())
R = []
for i in xrange(K):
    ia, ib = map(int, raw_input().split())
    R.extend([ia, ib])

R = sorted(R)
R.reverse()

count = 1
c = 0
r = R.pop()

for i in xrange(N):
    while count == r:
        c += 1
        if len(R) > 0:
             r = R.pop()
        else:
             break

    print c
    count += 1
    c = 0

Submission status: Accepted

Solution code:
def b():
    # N 個の都市があり、M 本の道路があります。
    # i(1≦i≦M) 番目の道路は、都市 ai と 都市 bi (1≦ai,bi≦N) を双方向に結んでいます。
    # 同じ 2 つの都市を結ぶ道路は、1 本とは限りません。
    # 各都市から他の都市に向けて、何本の道路が伸びているか求めてください。
    #
    # 制約
    # 2≦N,M≦50
    # 1≦ai,bi≦N
    # ai≠bi
    # 入力は全て整数である。
    n, m = map(int, input().split())
    city = [0]*n
    for i in range(m):
        ai, bi = map(int, input().split())
        city[ai-1] += 1
        city[bi-1] += 1
    for c in city: print(c)
    pass

b()

Submission status: Accepted

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

a=[flatten for inner in a for flatten in inner]
 
for i in range(N):
    b.append((a.count(i+1)))


c = list(map(str, b))

answer = '\n'.join(c)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    ans = [0]*N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        ans[ai] += 1
        ans[bi] += 1

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

Submission status: Accepted

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

road_list = [0] * n

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

for road in road_list:
  print(road)

Submission status: Accepted

Solution code:
import numpy as np
n,m=map(int,raw_input().split())
a=[]
b=[]
for k in range(m):
    aa,bb=map(int,raw_input().split())
    a.append(aa)
    b.append(bb)
a=np.array(a)
b=np.array(b)

for k in range(1,n+1):
    print(len(np.where(a==k)[0])+len(np.where(b==k)[0]))

Submission status: Accepted

Solution code:
n = input()
tmp_n = n.split(" ")

N = tmp_n[0]
M = tmp_n[1]
n_list = []

for i in range(int(M)):
    num = input()
    tmp_num = num.split()
    n_list.append(int(tmp_num[0]))
    n_list.append(int(tmp_num[1]))
    
for j in range(1,int(N)+1):
    count = 0
    for k in n_list:
        if k == j:
            count = count + 1        
    print(count)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
L = []
for i in range(N):
	L.append(0)
for i in range(M):
	a, b = list(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,raw_input().split(' '))
roads = [0 for _ in xrange(n)]
for i in xrange(m):
    a,b = map(int,raw_input().split(' '))
    a -= 1; b -=1
    roads[a] += 1
    roads[b] += 1
for i in roads:
    print i

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N, M = map(int, input().split())
list_a, list_b, ans = ( [], [], [] )
num = [ tmp for tmp in range(1,N+1) ]
for tmp in range(M):
    a, b = map(int, input().split())
    list_a.append(a)
    list_b.append(b)

for tmp in range(len(num)):
    x = list_a.count(num[tmp])
    y = list_b.count(num[tmp])
    ans.append(x+y)

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

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(count[i])

Submission status: Accepted

Solution code:
#coding:utf-8

from collections import defaultdict

if __name__ == "__main__":
    N, M = map(int, input().split(" "))

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

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

Submission status: Accepted

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

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

    return ls_ans    
    
ls_ans = prob_B(n=n, m=m)
[print(ls_ans[i]) for i in range(len(ls_ans))]

Submission status: Accepted

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

for e in Es:
    print(len(e))

Submission status: Accepted

Solution code:
n, m = input().split(' ',2)
a = []
for ii in range(int(n)):
    a.append(0)
for ii in range(int(m)):
    tmpA, tmpB = input().split(' ',2)
    a[int(tmpA) - 1] += 1
    a[int(tmpB) - 1] += 1
for ii in range(int(n)):
    print(a[ii])

Submission status: Accepted

Solution code:
import numpy as np
mat = np.zeros((50, 50)).astype(int)

N, M = list(map(int, input().split(' ')))
for m in range(M):
    i, j = list(map(int, input().split(' ')))
    i, j = i-1, j-1
    mat[i][j] += 1
    
for n in range(N):
    res = 0
    for i in range(N):
        res += mat[n][i]
        res += mat[i][n]
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cr = input().split()
c = int(cr[0])
r = int(cr[1])
i = 0
n = []
michi = []
citi = [0] * c
while(i < r):
    michi.append(input().split())
    i += 1
    pass
i = 0
while(i < r):
    src = int(michi[i][0])
    dst = int(michi[i][1])
    citi[src-1] += 1
    citi[dst-1] += 1
    i += 1
    pass
i = 0
while(i < c):
    print(citi[i])
    i += 1

Submission status: Accepted

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

d = []
for i in range(M):
	d = d + c[i]

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

Submission status: Accepted

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

x = input()
y=[]
y=x.split(" ")
N=int(y[0])
M=int(y[1])

z=[]
for i in range(M):
	temp1=input()
	temp2=temp1.split(" ")
	for j in temp2:
		j=int(j)
		z.append(j)

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

for i in z:
	dict[i]=dict[i]+1

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

Submission status: Accepted

Solution code:
#nm = '4 3'.split(' ')
#print(abc)
nm = input().split(' ')
vv = []
for i in range(int(nm[1])):
    a = input().split(' ')
    vv.append(int(a[0]))
    vv.append(int(a[1]))

for i in range(int(nm[0])):
    c = vv.count(1+i)
    if c != 0:
        print(c)
    else:
        print('0')

Submission status: Accepted

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

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

for i in range(n):
    count = 0
    for j in range(m):
        if a[j] == i+1:
            count += 1
        if b[j] == i+1:
            count += 1
    print (count)

Submission status: Accepted

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

deg = [0]*n

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

print('\n'.join(map(str,deg)))

Submission status: Accepted

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

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

road = sum(road,[])
#print(road)
    
for j in range(n):
   print (road.count(j+1))

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
kotae = [0]*N
for i in range(M):
 l=map(int, raw_input().split())
 for j in range(len(l)):
  kotae[l[j]-1]=kotae[l[j]-1]+1
for k in range(N):
 print kotae[k]

Submission status: Accepted

Solution code:
import sys
import numpy as np
n,m = [int(x) for x in sys.stdin.readline().split()]
r = np.zeros(n)
for i in range(m):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += 1
	r[b-1] += 1
for i in range(n):
	print(int(r[i]))

Submission status: Accepted

Solution code:
arnum = input().split()
n = int(arnum[0])
m = int(arnum[1])
road = []
for i in range(m):
    lists = [int(x) for x in input().split()]
    road.append(int(lists[0]))
    road.append(int(lists[1]))
for j in range(1,n+1):
    print(road.count(j))

Submission status: Accepted

Solution code:
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N_toshi=int(hyo[0])
M_miti=int(hyo[1])

hindo=[0]*N_toshi

for idx in range(0,M_miti,1):
    mozir=input()
    hyo=mozir.split(' ')
    hashis=(int(mono)-1 for mono in hyo)
    for tenn in hashis:
        hindo[tenn]=hindo[tenn]+1

for tenn in hindo:
    print(tenn)

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)
    roads.append(b)

for i in range(1,N+1):
    cnt = 0
    for j in roads:
        if j == i:
            cnt+=1
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

from itertools import chain

N,M=map(int,raw_input().split())
road=[0]*M
for i in range(M):
    road[i]=map(int,raw_input().strip().split())

road=list(chain.from_iterable(road))

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

Submission status: Accepted

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

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

for key in sorted(dic.keys()):
    print(dic[key])

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	N, M = map(int, input().split())
	n=[]
	for j in range(N):
		n.append(0)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(M)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(f.count(i))

Submission status: Accepted

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

for i in xrange(M):
    print cnt[i]

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(n):
    i+=1
    ans=list.count(i)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    m = [None, None] * M
    i = 0
    while i < M * 2:
        a, b = map(int, input().split())
        m[i] = a
        m[i+1] = b
        i += 2

    for s in range(1, N + 1):
        ans = m.count(s)
        print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N,M = map(int, input().split())
count = [0 for i in range(N+1)] #0-N番の道路の個数（０番目は使用しないように注意)

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

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

Submission status: Accepted

Solution code:
def int_input():
    line = input()
    return [int(x) for x in line.split()]

n, m = int_input()
cities = {}

for i in range(n):
    cities[i+1] = []

for i in range(m):
    a, b = int_input()
    cities[a].append(b)
    cities[b].append(a)

for i in sorted(cities.keys()):
    print(len(cities[i]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

line = input().split(' ')
N = int(line[0])
M = int(line[1])

count_list = [0 for i in range(N)]

for i in range(M):
    line = input().split(' ')
    for j in line:
        count_list[int(j)-1] += 1


if __name__ == '__main__':
    for count in count_list:
        print(count)

Submission status: Accepted

Solution code:
# coding: utf-8

from collections import Counter

n, m = map(int, raw_input().split())
f = [int(flatten) for _ in range(m) for flatten in raw_input().split()]
c = Counter(f)

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

Submission status: Accepted

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


dp = {}
for i in range(M):
    a = ab[i][0]
    b = ab[i][1]
    if a not in dp:
        dp[a] = 1
    else:
        dp[a] += 1

    if b not in dp:
        dp[b] = 1
    else:
        dp[b] += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for c in city:
    print(c)

Submission status: Accepted

Solution code:
import numpy as np
n,m = input().split()
n = int(n)
m = int(m)
count = np.zeros(n)
for i in range(m):
    a, b = input().split()
    count[int(a)-1] += 1
    count[int(b)-1] += 1

for i in count:
    print(int(i))

Submission status: Accepted

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

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

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

for j in range(N):
    
    for k in range(M):
        if a[k]==j+1:
            c[j]+=1

        if b[k]==j+1:
            c[j]+=1

    print(c[j])

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter
N,M = list(map(int,input().split()))

a = []

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

count = Counter(a)
for i in range(N):
    print (count[i+1])

Submission status: Accepted

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

r = []
for i in range(m):
    r += [int(i) for i in input().split()]

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

Submission status: Accepted

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

path_num = [0 for i in range(N)] 
for i in range(M):
    k, l = map(int, input().split())
    path_num[k - 1] += 1
    path_num[l - 1] += 1

for num in path_num:
    print(num)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    r = [0] * n
    for _ in range(m):
        a,b = LI_()
        r[a] += 1
        r[b] += 1
    return '\n'.join(map(str, r))

print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))

road_count_from_city = [0 for i in range(N)]

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, raw_input().split())
a = []
b = []
for _ in range(M):
    _a, _b = map(int, raw_input().split())
    a.append(_a)
    b.append(_b)

ans = [0] * N
for i in range(0, N):
    ans[i] = a.count(i + 1) + b.count(i + 1)
    print ans[i]

Submission status: Accepted

Solution code:
import collections


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

    streets = collections.defaultdict(list)

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [0 for i in range(N)]
for m 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:
a = list(map(int,input().split(" ")))
b = list()
c = list()
tmp = list()

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

for i in range(a[0]):
    print(b.count(i + 1))

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split(' '))
d = {}

for i in range(m):
	a, b = map(int, raw_input().split(' '))
	if d.has_key(a):
		d[a] += 1
	else:
		d[a] = 1
	if d.has_key(b):
		d[b] += 1
	else:
		d[b] = 1

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

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
mat = np.zeros((N, N))
for i in range(M):
    a, b = map(int, input().split())
    mat[a-1][b-1] += 1
    mat[b-1][a-1] += 1

ans = np.sum(mat, axis=1)
for i in range(N):
    print(int(ans[i]))

Submission status: Accepted

Solution code:
def rren(): return list(map(int, input().split()))


N, M = rren()
road = [[0 for i in range(N+1)] for j in range(N+1)]

for i in range(M):
    a, b = rren()
    road[a][b] += 1
    road[b][a] += 1

for i in range(1, N+1):
    count = 0
    for j in range(1, N+1):
        count += road[i][j]
    print(count)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

for i in c:
	print i

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

mp = [[0]*n for _ in xrange(n)]

for idx in xrange(m):
    a, b = map(int, raw_input().split())
    mp[a-1][b-1] += 1
    mp[b-1][a-1] += 1

for idx in range(n):
    print sum(mp[idx])

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(int,input().split())
	l[a-1] += 1
	l[b-1] += 1

for i in l:
	print(i)

Submission status: Accepted

Solution code:
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

N, M = rdi()
a = []
b = []
for i in range(M):
        ai, bi = rdi()
        a.append(ai)
        b.append(bi)

c = {}
for i in range(N):
        c[i+1] = 0
for i in range(M):
        ai = a[i]
        bi = b[i]
        c[ai] += 1
        c[bi] += 1
for i in range(N):
        print c[i+1]

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    m = int(lst[1])

    ans_dic = defaultdict(int) #都市番号 -> 本数
    for i in range(m):
        line = sys.stdin.readline()
        lst = line.split()
        a = int(lst[0])
        b = int(lst[1])
        ans_dic[a] += 1
        ans_dic[b] += 1

    for i in range(1, n+1):
        print("%d" % ans_dic[i])
    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

Solution code:
def linput():
    return list(map(int,input().split(" ")))


N,M=linput()
L=[0]*N
for i in range(M):
    a,b=linput()
    L[a-1]+=1
    L[b-1]+=1

for l in L:
    print(l)

Submission status: Accepted

Solution code:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

    for n in range(N):
        print(sum(R[n]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Accepted

Solution code:
temp=input().split()
N=int(temp[0])
M=int(temp[1])
ab=[[int(j)-1 for j in input().split()] for i in range(M)]

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

for i in range(M):
	place[ab[i][0]].append(ab[i][1])
	place[ab[i][1]].append(ab[i][0])

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

Submission status: Accepted

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

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

for city in city_list:
    print(city)

Submission status: Accepted

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

n,m = map(int, raw_input().split())
cnt = [0]*n
    
for i in range(m):
    a,b = map(int, raw_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

if __name__ == '__main__':
    n, m = map(int, input().split())

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

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

Submission status: Accepted

Solution code:
# B
import numpy as np
N, M = map(int, input().split())
mat = np.zeros((N, N))
for i in range(M):
    a, b = map(int, input().split())
    mat[a-1, b-1] += 1
    mat[b-1, a-1] += 1

for n in range(N):
    print(int(mat[n, :].sum()))

Submission status: Accepted

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

roads_cnt=[0]*N
for i in range(M):
    a_i,b_i=map(int,input().split())
    roads_cnt[a_i-1] +=1
    roads_cnt[b_i-1] +=1

for road_cnt in roads_cnt:
    print(road_cnt)

Submission status: Accepted

Solution code:

# coding: utf-8
import numpy as np

if __name__ == "__main__":
	n, m = map(int, input().split())

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

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

Submission status: Accepted

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

cnt = [0 for _ in range(N)]
for a, b in E:
    cnt[a-1] += 1
    cnt[b-1] += 1

for v in cnt:
    print v

Submission status: Accepted

Solution code:
import numpy as np

n, m = map(int, raw_input().split())
ans = np.zeros(n)
for i in range(m):
    l = map(int, raw_input().split())
    ans[l[0] - 1] += 1
    ans[l[1] - 1] += 1

for i in ans:
    print int(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

import sys
import os
import math

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

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

    A[a] += 1
    A[b] += 1

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