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

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    res = [0] * (N + 1)

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

N, M = map(int, input().split())
# 都市Aと都市Bを結ぶ路線M
A_B = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * N

for a, b in A_B:
    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())

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

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

for i in range(len(ab)):
    dict[ab[i][0]] += 1
    dict[ab[i][1]] += 1

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

Submission status: Accepted

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

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

ans = [0] * n

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

for i in ans:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

n, m = map(int,input().split())
cnt = [0] * 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)

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int, input().split())
ans = np.zeros(n, dtype=int)
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())

ar = [0] * n

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

Submission status: Accepted

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

c = [[] for _ in range(n + 1)]

for a, b in edges:
    c[a].append(b)
    c[b].append(a)

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

Submission status: Accepted

Solution code:
def solve():
    N, M = [int(i) for i in input().split()]
    R = [[] for _ in range(N)]
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        R[a - 1].append(b)
        R[b - 1].append(a)
    for r in R:
        print(len(r))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    import numpy as np

    N, M = map(int, input().split())
    ab = np.array([list(map(int, input().split())) for _ in range(M)])
    for i in range(1, N+1):
        print(np.count_nonzero(ab == i))


main()

Submission status: Accepted

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

for i in city:
    print(i)

Submission status: Accepted

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

road_dict = {}
for road in road_list:
  first_city = road[0]
  second_city = road[1]
  first_city_road_list = road_dict.get(first_city, [])
  first_city_road_list.append(second_city)
  road_dict[first_city] = first_city_road_list
  
  second_city_road_list = road_dict.get(second_city, [])
  second_city_road_list.append(first_city)
  road_dict[second_city] = second_city_road_list

for i in range(1, N+1):
  city_road_list = road_dict.get(i, [])
  road_num = len(city_road_list) if city_road_list != [] else 0
  print(road_num)

Submission status: Accepted

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

for i in ans:
    print(i)

Submission status: Accepted

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

for i in roads:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n,m = map(int, input().split())
    A = []
    B = []
    for _ in range(m):
        a,b = map(int, input().split())
        A.append(a)
        B.append(b)
    AB = []
    AB.extend(A)
    AB.extend(B)
    for i in range(n):
        count = 0
        for j in range(len(AB)):
            if i+1 == AB[j]:
                count += 1
        print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
c={i:0 for i in range(1,n+1)}
for a,b in [list(map(int,input().split())) for i in range(m)]:
  c[a]+=1;c[b]+=1
print(*c.values(),sep='\n')

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in l[1:]:
    print(i)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for i in range(m):
    l+=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())
ab=[]
for i in range(M):
    ab+=list(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())
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())
l=[0]*n
for i in range(m):
    p,q=map(int,input().split())
    l[p-1]+=1
    l[q-1]+=1
print(*l,sep='\n')

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
def actual(N, M, A, B):
    AB = A + B

    counts = [AB.count(i) for i in range(1, N + 1)]
    
    return '\n'.join(map(str, counts))

N, M = map(int, input().split())
A, B = [], []
for _ in range(M):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
print(actual(N, M, A, B))

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)]
n = 1
while True:
    for i in range(M):
        for j in range(2):
            if n == ab[i][j]:
                ans[n-1] += 1
    if n == N:
        break
    n += 1
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

data = [[0 for i in range(N)] for j in range(N)]

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

Submission status: Accepted

Solution code:
lst1 = input().split()

N = int(lst1[0])
M = int(lst1[1])

lst2 = []

for i in range(M):
   lst2.append(input().split())

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

for i in range(M):
   for j in range(2):
      lst3[ int(lst2[i][j]) - 1 ] += 1

for i in range(N):
   print(lst3[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)]
cnt = [0 for i in range(N)]

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

for i in range(M):
    cnt[a[i]-1] += 1
    cnt[b[i]-1] += 1

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

for j in range(M):
    cnt[a[j]-1]+=1
    cnt[b[j]-1]+=1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

g = {i:0 for i in range(N)}

for a,b in ab:
    g[a-1] += 1
    g[b-1] += 1
    
for i in g.values():
    print(i)

Submission status: Accepted

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

g = {i:[] for i in range(N)}

for a,b in ab:
    g[a-1].append(b)
    g[b-1].append(a)
    
for i in g.values():
    print(len(i))

Submission status: Accepted

Solution code:
N,M= map(int,input().split())
AB = [list(map(lambda x:x-1,[int(i) for i in input().split()])) for _ in range(M)]
c = [0]*N

for i in range(M) :
    c[AB[i][0]] += 1
    c[AB[i][1]] += 1

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

Submission status: Accepted

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

c_list=[0]*n

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

for i in c_list:
    print(i)

Submission status: Accepted

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

for i in range(n):
  print(ab.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 (n):
  print (l.count (i+1))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, M = map(int, input().split())
a = []
for i in range(M):
    b, c = map(int, input().split())
    a.append(b)
    a.append(c)

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

Submission status: Accepted

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

for i in w:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#B - Counting Roads
N,M = map(int,input().split())
a = []
b = []
for _ in range(M):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
start = a + b
count = [0]*N
for i in range(len(start)):
    count[start[i]-1] += 1
    
for o in range(N):
    print(count[o])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline
    n, m = [int(x) for x in input().rstrip().split(" ")]

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

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

    print("\n".join([str(a) for a in ans]))


if __name__ == "__main__":
    resolve()

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):
    print(sum(ab,[]).count(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# abc061 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 3
1 2
2 3
1 4"""
        output = """2
2
1
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 5
1 2
2 1
1 2
2 1
1 2"""
        output = """5
5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8"""
        output = """3
3
2
2
2
1
1
2"""
        self.assertIO(input, output)


def resolve():
    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])


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
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,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
c=[0]*n
for i in range(m):
    c[ab[i][0]-1]+=1
    c[ab[i][1]-1]+=1
for i in range(n):
    print(c[i])

Submission status: Accepted

Solution code:
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
t = defaultdict(int)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    t[a]+=1
    t[b]+=1
for j in range(1, n+1):
    print(t[j])

Submission status: Accepted

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

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

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

  
if __name__ == "__main__":
  	main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
#dic = {}
#for i in range(m):
#    a,b = map(int,input().split())
#    dic.setdefault(a,0)
#    dic[a] += 1
#    dic.setdefault(b,0)
#    dic[b] += 1
#for j in range(1,n+1):
#    print(dic[j])
ans = [int(0) for i in range(n+1)]
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())
c = [0]*n
S = []
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())
ab = []
for i in range(m):
    a,b = map(int, input().split())
    ab.append(a)
    ab.append(b)

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

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:
import sys
def input(): return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a = sum([list(map(int, input().split())) for _ in range(M)], [])
for n in range(1, N+1):
  print(a.count(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 a in A:
    # if a != 0:
    print(a)

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 m in range(M):
  ans[ab[m][0]-1] += 1
  ans[ab[m][1]-1] += 1

for a in ans:
  print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

tmp = [0] * N

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print("\n".join([str(s) for s in 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 ci in c:
    print(ci)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

city = [0]*(n+1)

for _ in range(m):
    a, b = inintm()
    city[a] += 1
    city[b] += 1

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

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())
abl=[list(map(int,input().split())) for _ in range(m)]

ans=[0]*n
for ab in abl:
    ans[ab[0]-1]+=1
    ans[ab[1]-1]+=1

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

C=[0]*(N+1)

for i in range(M):
    C[A[i]]+=1
    C[B[i]]+=1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from fractions import gcd


def read():
    N, M = map(int, input().strip().split())
    AB = []
    for i in range(M):
        a, b = map(int, input().strip().split())
        AB.append((a-1, b-1))
    return N, M, AB


def solve(N, M, AB):
    n_neighbors = [0 for i in range(N)]
    for a, b in AB:
        n_neighbors[a] += 1
        n_neighbors[b] += 1
    for x in n_neighbors:
        print(x)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pairs = []
res = []
for _ in range(m):
	pair = list(map(int, input().split()))
	pairs.append(pair)
for i in range(1, n+1):
	c = 0
	for j in pairs:
		if i in j:
			c += 1
	res.append(c)
for i in res:
	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 j in range(N):
    print(ans[j])

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)

Submission status: Accepted

Solution code:
N,M = (int(T) for T in input().split())
Road = []
for TM in range(0,M):
    Road.extend([int(T) for T in input().split()])
for TN in range(1,N+1):
    print(Road.count(TN))

Submission status: Accepted

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