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:
from collections import defaultdict


class Graph(object):
    """
    隣接リストによる無向グラフ
    重み無しで距離は１
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst):
        self.graph[src].append(dst)
        self.graph[dst].append(src)

    def get_nodes(self):
        return self.graph.keys()


def main():
    N, M = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(M)]
    g = Graph()
    for e in ab:
        g.add_edge(e[0], e[1])

    for i in range(N):
        print(len(g.graph[i+1]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

for p in l:
  print(p)

Submission status: Accepted

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

for i in range(m):
  tosi[ab[i][0]]+=1
  tosi[ab[i][1]]+=1
tosi.pop(0)
for i in tosi:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

i=0
while i<M:
    a,b=map(int,input().split())
    ans[a]+=1
    ans[b]+=1
    i+=1

j=1
while j<=N:
    print(ans[j])
    j+=1

Submission status: Accepted

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

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

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

for i in range(1,n+1):
    for j in range(m):
        if i in li[j]:
            city[i] += 1
    print(city[i])

Submission status: Accepted

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

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

for x in d:
    print(x)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print("\n".join(map(str, edges)))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n, m = map(int, input().split()) # 頂点の数、辺の数
    edge = [[] * n for i in range(n)] # rangeに頂点の数。繋がっている頂点を投入するリスト
    for i in range(m): # rangeに辺の数
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        edge[x].append(y)
        edge[y].append(x) # 有向ならコメントアウト
    for i in range(n):
        print(len(edge[i]))
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
lst = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lst[a].append(b)
    lst[b].append(a)
for l in lst:
    print(len(l))

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):
  x = len(l)
  z = 0
  for y in range(x):
    if i+1 == l[y]:
      z += 1
  print(z)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
ab = [LIST() for _ in range(M)]
cnt = [0]*N

for i in range(M):
	cnt[ab[i][0]-1] += 1
	cnt[ab[i][1]-1] += 1

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

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    a_b_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        a_b_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = [0] * N
    for a, b in a_b_arr:
        cnt[a-1] += 1
        cnt[b-1] += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    for i in range(N):
        print(cnt[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
for i in range(1,n+1):
    print(len(dic[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())
city = [0]*N
road = [0]*M
for i in range(M):
  road[i] = list(map(int,input().split()))
for i in range(M):
  city[road[i][0]-1] += 1
  city[road[i][1]-1] += 1
for j in range(N):
  print(city[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,m=MI()
lis=[[]for i in range(n)]
for i in range(m):
    a,b=MI()
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(n):
    print(len(lis[i]))

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(m)]

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k] -1] += 1

    for l in range(n):
        print(towns[l])
resolve()

Submission status: Accepted

Solution code:

n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}#辞書同士の追加はupdate

for i in range(1,n+1):
    d[i] =0
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
P = []
for i in range(M):
    P.append([int(k) for k in input().split()])
for t in range(N):
    cnt = 0
    for r in range(M):
        if t+1 in P[r]:
            cnt += 1
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cnt = [0]*(n+1)
for _ in range(m):
    i1, i2 = map(int, input().split())
    cnt[i1] += 1
    cnt[i2] += 1
print("\n".join(map(str, cnt[1:])))

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
c = []
for _ in range(M):
    a, b= map(int, input().split())
    c.append(a)
    c.append(b)
for i in range(N):
    print(c.count(i+1))

Submission status: Accepted

Solution code:
import collections

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

a = [v[0] for v in ab]
b = [v[1] for v in ab]
a.extend(b)
c = collections.Counter(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
    print(len(p[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
[print(i) for i in 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("\n".join(map(str,ans)))

Submission status: Accepted

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

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

c=[]
for i in range(1,N+1):
  c.append(a.count(i)+b.count(i))
  print(a.count(i)+b.count(i))

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
roads = [0] * n
for _ in range(m):
    i = list(map(lambda x:int(x)-1,input().split()))
    for ix in i: roads[ix] += 1
for x in roads: print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

K=[0 for j in range(N)]


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m = MII()
    loads = {i: [] for i in range(n)}
    for i in range(m):
        a, b = MIIZ()
        loads[a].append(b)
        loads[b].append(b)
    for l in loads.values():
        print(len(l))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
way=[0]*(N+1)
for i in range(M):
    a,b=map(int,input().split())
    way[a]+=1
    way[b]+=1
for i in range(N+1):
    if i!=0:
        print(way[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())
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())
graph = {i:[] for i in range(1, n+1)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
for i in range(1, n+1):
  print(len(graph[i]))

Submission status: Accepted

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

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

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

for g in graph:
    print(g)

Submission status: Accepted

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

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 ans:
    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())
  a -= 1
  b -= 1
  ans[a] += 1
  ans[b] += 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)]
for i in range(1,n+1):
  count = 0
  for s in ab:
    if i in s:
      count += 1
  print(count)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.buffer.readline
n,m=map(int,input().split())
cnt=[0]*(n+1)
for _ in range(m):
    a,b=map(int,input().split())
    cnt[a]+=1
    cnt[b]+=1
cnt.pop(0)
print(*cnt,sep="\n")

Submission status: Accepted

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

c = []
for _ in range(M):
  a = input().split()
  c.extend(a)
  
for i in range(1,N+1):
  print(c.count(str(i)))

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

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

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


for a in res:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)] #n行にmつずつ入力される整数
ans_li = [0]*n
for i, j in li:
    ans_li[i-1] += 1
    ans_li[j-1] += 1
for x in ans_li:
    print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [0]*n

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

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

Submission status: Accepted

Solution code:
N,M=(int(x) for x in input().split())
a_list=[]
b_list=[]
for i in range(M):
  a,b=(int(x) for x in input().split())
  a_list.append(a)
  b_list.append(b)
count=[0]*N
c_list=a_list+b_list
for r in c_list:
  count[r-1]+=1

[print(l) for l in count]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(m)]
G = [[] for _ in range(n)]
for l in L:
    G[l[0]-1].append(l[1]-1)
    G[l[1]-1].append(l[0]-1)
for g in G:
    print(len(g))

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 j in range(1, n+1):
    print(l[j])

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

for j in L:
    for v in j:
        d[v] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
Load = [list(map(int,input().split())) for i in range(M)]
List = []
for i in range(N):
  List.append(0)
for i in range(len(Load)):
  List[Load[i][0]-1] += 1
  List[Load[i][1]-1] += 1
for i in List:
  print(i)

Submission status: Accepted

Solution code:
def resolve():
    N, M = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for i in range(M)]
    import collections
    d = collections.OrderedDict([(i, 0) for i in range(1, N+1)])
    for ab in AB:
        d[ab[0]] += 1
        d[ab[1]] += 1
    for k in d:
        print(d[k])


if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    for i in res:
        print(i)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
xy = [map(int,input().split())for _ in range(M)]
x,y=[list(i) for i in zip(*xy)]
city=[0]*N
for i in range(M):
    for n in range(1,N+1):
        if x[i]==n:
            city[n-1]=city[n-1]+1
        if y[i]==n:
            city[n-1]=city[n-1]+1
for i in range(N):
    print(city[i])

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
d = {x:0 for x in range(1,N+1)}
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())
L = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
for l in L:
    print(len(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8
n, m = map(int, input().split())
ans = [0] * n

for i 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())
#ab = [list(map(int, input().split())) for _ in range(M)]
ab = [list(map(int, input(). split())) for i in range(M)]
#print(ab)

cnt_list = [0]*N

for _list in ab:
	for j in _list:
		cnt_list[j-1]+=1
for i in cnt_list:
	print(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(len([1 for x in l if x==i+1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import collections
n,m = map(int,input().split())
A =[list(map(int,input().split())) for _ in range(m)]
B = list(itertools.chain.from_iterable(A))
S = collections.Counter(B)
for i in range(1,n+1):
    print(S[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:
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    path = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
    for i in range(N):
        print(len(path[i]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

N, M = list(map(int, input().split()))
ab_list = []

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

counter = collections.Counter(ab_list)
for i in range(N):
    print(counter[i + 1])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = []
anslist = [0]*n
while True:
  try:
    tmpa,tmpb = map(int,input().split())
    n = (tmpa,tmpb)
    l.append(n)
    
    
  except:
    break
    
for i,j in l:
  anslist[i-1] +=1
  anslist[j-1] +=1
  
for i in anslist:
  print(i)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N, M = map(int, readline().split())
    load = [0]*N
    for _ in range(M):
        a, b = map(int, readline().split())
        load[a-1]+=1
        load[b-1]+=1
    for i in range(N):
        print(load[i])




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int,input().split())
d = defaultdict(int)
for _ in range(M):
    a, b = map(int,input().split())
    d[a] += 1
    d[b] += 1
for i in range(1,N+1):
    print(d[i])

Submission status: Accepted

Solution code:
from sys import stdin
import sys

[N, M] = list(map(int, stdin.readline().rstrip().split()))

a = []
for i in range(M):
    a.append(list(map(int, stdin.readline().rstrip().split())))

city = [[] for i in range(N+1)]

for i in range(M):
    [s, d] = a[i]
    city[s].append(d)
    city[d].append(s)

for i in range(1, N+1):
    if len(city[i]) >= 0:
        print(len(city[i]))

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(2):
    for j in range(m):
        ans[a[j][i]-1] += 1
print(*ans, sep='\n')

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

counter = collections.Counter(li)
for i in range(N):
    print(counter[i + 1]) if i + 1 in counter else print(0)

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
input_lines = [[int(j)-1 for j in input().split()]for i in range(m)]

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

for line in input_lines:
    map_list[line[0]][line[1]]+=1
    map_list[line[1]][line[0]]+=1

for li in map_list:
    print(sum(li))

Submission status: Accepted

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

for road in city:
    roads_count[road[0]-1] += 1
    roads_count[road[1]-1] += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
ans = np.zeros(N+1,dtype="int64")
for i in range(M):
    a, b = map(int,input().split())
    ans[a] += 1
    ans[b] += 1

print(*ans[1:],sep="\n")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))