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

Submission status: Accepted

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

ANS=[0]*(N+1)
for a,b in R:
    ANS[a]+=1
    ANS[b]+=1

for ans in ANS[1:]:
    print(ans)

Submission status: Accepted

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

ans = [0] * N

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

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:
import math

# 下記のように入力する場合のコード
# 5
# 2 5 9 6 5

city_road = list(map(int, input().split())) #cityの数、roadの数の配列
arr = [0]*city_road[1]
for i in range(city_road[1]):
    arr[i] = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

count = [0]*city_road[0]
for j in range(city_road[0]):
    for i in range(city_road[1]):
        if j+1 in arr[i]:
            count[j] += 1

for i in range(city_road[0]):
    print(count[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
print(*c, sep='\n')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
Loads = [[int(i) for i in input().split()] for j in range(M)]
ans = [0]*N

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(n):
    count = 0
    for j in range(m):
        count += l[j].count(str(i+1))
    print(count)

Submission status: Accepted

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

for i in range(road):
    spot = spot_list[i]
    for j in range(2):
        road_list.append(spot[j])

for k in range(1,city+1):
    count = 0
    for l in range(road*2):
        if k == road_list[l]:
            count += 1
    print(count)

Submission status: Accepted

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

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

ans=[0]*n
for i in range(m):
  ans[lst[i][0]-1] += 1
  ans[lst[i][1]-1] += 1
for i in range(n):
  print(ans[i])

Submission status: Accepted

Solution code:
# 2019/05/25
# AtCoder Beginner Contest 061 - B

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

# Output
for i in range(1, n+1):
    print(rcnt[i])

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
"""解き方
[入力例1]
4 3
1 2
2 3
1 4

道路\都市 | 1 | 2 | 3 | 4
           ○   ○ 
               ○   ○
           ○           ○

[出力例1]
2
2
1
1
"""
def solve():
    N, M = list(map(int, input().split()))
    road_cnt = [0 for i in range(N)]

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

        road_cnt[a] += 1
        road_cnt[b] += 1
    
    for cnt in road_cnt:
        print(cnt)


if __name__ == "__main__":
    solve()

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 j in ls:
    print(j)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = [0] * N
for x, y in [list(map(int, input().split())) for i in range(M)]:
    ans[x-1] += 1
    ans[y-1] += 1
print("\n".join(map(str, ans)))

Submission status: Accepted

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

for j in range(1,N+1):
  ans = 0
  for k in range(M):
    a = lst1[k].count(j)
    #print(j,k,a)
    ans += a
  print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
ans = [0]*N
for r in AB:
    for c in r:
        ans[c-1] += 1
print(*ans, sep='\n')

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for _ in range(M):
    l, r = map(int, input().split())
    cnts[l] += 1
    cnts[r] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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


ab = []
for _ in range(M):
  ab.append(list(map(int, input().split())))
  
           
bridges = [0] * N
            
for c in range(N):
  for i in range(M):
    if c+1==ab[i][0] or c+1==ab[i][1]:
      bridges[c] += 1
            
 
for _ in range(N):
  print(bridges[_] )

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque, Counter
N, M = map(int, input().split())
X = deque(maxlen=2 * M)
for _ in range(M):
    a, b = input().split()
    X.append(a)
    X.append(b)
c = Counter(X)
for i in range(1, N+1):
    i = str(i)
    print(c[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

city = [0] * N

for i in range(M):
    tmp1, tmp2 = map(int,input().split())
    city[tmp1-1] += 1
    city[tmp2-1] += 1
for i in range(N):
    print(city[i])

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
import collections
input = sys.stdin.readline

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


def main():
    ctr = collections.Counter(a + b)
    for i in range(1, N+1):
        print(ctr[i])


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


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = [0] * N

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N,M=ipt()
a=ipt(M)

for i in range(1,N+1):
    ans_list=[]
    for j in range(M):
        if a[j][0] == i:
            ans_list.append(a[j][1])
        if a[j][1] == i:
            ans_list.append(a[j][0])
    print(len(ans_list))

Submission status: Accepted

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

Submission status: Accepted

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

for k in range(n):
    print(a.count(k+1))

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 x in l:
  print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7


N,M = map(int,input().split())
loads = [[0 for i in range(N)]for j in range(N)]
for i in range(M):
    load = [int(i) for i in input().split()]
    loads[load[0]-1][load[1]-1] += 1
    loads[load[1]-1][load[0]-1] += 1

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

Submission status: Accepted

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

for i in range(M):
  l.extend(list(map(int, input().split())))
for i in range(1,N+1):
  print(l.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 j in range(1,n+1):
    print(l.count(j))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = {x: 0 for x in range(1, n+1)}

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

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

Submission status: Accepted

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

Submission status: Accepted

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

from itertools import chain
ab = list(chain.from_iterable(ab))
for _ in range(1, N + 1):
    cnt = ab.count(_)
    print(cnt)

Submission status: Accepted

Solution code:
#61
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 range(n):
    print(x[i])

Submission status: Accepted

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

Submission status: Accepted

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

num = [0] * N

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

for i in num:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for n in nums.values():
    print(n)

Submission status: Accepted

Solution code:
# ABC061B - Counting Roads
n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
ans = [0] * n
for i in lst:
    for j in i:
        ans[j - 1] += 1
for i in ans:
    print(i)

Submission status: Accepted

Solution code:


N,M = map(int, input().split())
ret = [0 for i in range(N)]
for _ in range(M):
  ab = list(map(int, input().split()))
  for i in ab:
    ret[i-1] += 1

for i in ret:
  print(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 a in ans:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

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

for i in range(len(ab_list)):
    ans_list.append(ab_list[i][0])
    ans_list.append(ab_list[i][1])

ans_cnt = Counter(ans_list)

for i in range(1, n+1):
    try:
        print(ans_cnt[str(i)])
    except IndexError:
        print(0)

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:

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

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

    return n, m, edges

def submit():
    n, m, edges = read_input()

    edges_dic = {}
    for i in  range(n):
        edges_dic[i + 1] = []

    for e in edges:
        (s, t) = e
        edges_dic[s].append(t)
        edges_dic[t].append(s)

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

if __name__ == '__main__':
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
a_list = []
b_list = []
cnt = 0
cnt_list = []
for i in range(M):
    a,b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)
for i in range(1,N+1):
    for j in range(M):
        if i == a_list[j] or i == b_list[j]:
            cnt += 1
    cnt_list.append(cnt)
    cnt = 0
for i in range(len(cnt_list)):
    print(cnt_list[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

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

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())
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
[print(x) for x in l]

Submission status: Accepted

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

Submission status: Accepted

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

b = []
for i in range(N):
  b.append([0] * N)

for i in range(M):
  b[a[i][0]-1][a[i][1]-1] += 1
  b[a[i][1]-1][a[i][0]-1] += 1
  
for i in range(N):
  print(sum(b[i]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

city = [0] * n

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

for l in city:
    print(l)

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

for i in road:
    print(i)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, m =f()
    con = [0] * n
    for i in range(m):
        x, y = f()
        con[x-1] += 1
        con[y-1] += 1

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

solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

l = []
for i in range(M):
    l.append(AB[i][0])
    l.append(AB[i][1])
cnt = Counter(l)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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):
  c=l.count(j)
  print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = []
n,m = map(int,input().split())
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:
n,m=map(int,input().split())
a=[]
for i in range(m):a.extend(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):
    a1,b1=[int(i) for i in 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())

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

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())
d = dict.fromkeys(list(range(1, n + 1)), 0)
for i 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())
A=[]
for i in range(M):
    A.extend(sorted(list(map(int,input().split()))))
for j in range(1,N+1):
    print(A.count(j))

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    a = []
    b = []
    ans = [0]*(N+1)
    # for i in range(N+1):
    #     ans.append(0)
    for i in range(M):
        s1,s2 = (int(_) for _ in input().split())
        a.append(s1)
        b.append(s2)

    for i in range(M):
        ans[a[i]] +=1
        ans[b[i]] +=1
    print('\n'.join(str(_) for _ in ans[1:]))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in a:
    print(i)

Submission status: Accepted

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

maps = {i:0 for i in range(1, N+1)}

for load in ls:
    maps[load[0]] += 1
    maps[load[1]] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

nodes = [0] * N

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

for i in range(0,N):
    print(nodes[i])

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

Submission status: Accepted

Solution code:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n, m = nm()
ab = [nl() for i in range(m)]
ans = [0 for i in range(n)]
for i in range(m):
    ans[ab[i][0] - 1] += 1
    ans[ab[i][1] - 1] += 1
for i in range(n):
    print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import OrderedDict
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
X = OrderedDict([(i + 1, []) for i in range(N)])
for a, b in L:
    X[a].append(b)
    X[b].append(a)
for _, x in X.items():
    print(len(x))

Submission status: Accepted

Solution code:
import numpy as np
n, m = map(int, raw_input().split())
arr = np.zeros(n, dtype=int)

for i in range(m):
	a = map(int, raw_input().split())
	arr[a[0]-1] += 1
	arr[a[1]-1] += 1

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

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())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
for i in cnt:
    print(i)