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: Wrong Answer

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

R = sorted(R)
R.reverse()

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

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

    print c
    count += 1
    c = 0

Submission status: Wrong Answer

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

R = sorted(R)
R.reverse()

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

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

Submission status: Wrong Answer

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

R = sorted(R)

count = 1
c = 0
for i in xrange(len(R)):
    if count == R[i]:
        c += 1
    else:
        print c
	count += 1
	c = 1
print c

Submission status: Wrong Answer

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


def main():
    n, m = (int(x) for x in input().split())
    adj_list = [set() for _ in range(n)]
    for _ in range(m):
        a, b = (int(x) - 1 for x in input().split())
        adj_list[a].add(b)
        adj_list[b].add(a)
    for vs in adj_list:
        print(len(vs))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


c = list(map(str, b))

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

Submission status: Wrong Answer

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


c = list(map(str, b))

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

Submission status: Wrong Answer

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

R = np.sort(R)

count = 1
c = 0
for i in xrange(R.shape[0]):
    if count == i:
        c += 1
    else:
        print c
	count += 1
	c = 0

Submission status: Wrong Answer

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

road_list = [0] * n

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

for road in road_list:
  if(road != 0):
    print(road)

Submission status: Wrong Answer

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


for i in range(N):
    b.append((a.count(i+1)))
results_int = map(str, b)
answer = " ".join(results_int)
print(answer)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

roadarray = []

for i in range(int(M)):
  roadarray.append(0)
  x = i + 1
  for j in range(len(array)):
      if array[j] == x:
        roadarray[i] += 1

for i in range(len(roadarray)):
  print(roadarray[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

count_dict = collections.Counter(roads)

for i in count_dict.values():
    print(i)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

from collections import Counter

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

for k, v in sorted(c.items()):
    print v

Submission status: Wrong Answer

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

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

for j in range(n):
    print (road.count(n-1))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

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

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

Submission status: Wrong Answer

Solution code:
import collections

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

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

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

Submission status: Wrong Answer

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

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

for i in d.values():
	print i

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import collections

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

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

for key, val in dic.items():
    print(val)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c, r = map(lambda x: int(x), input().split())
total = [0] * c
for i in range(r):
    f, s = map(lambda x: int(x), input().split())
    total[f - 1] += 1
    total[s - 1] += 1

for number in total:
    print(number)

Submission status: Accepted

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

Submission status: Accepted

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

l = []
for i in range(m):
    x,y = map(int,input().split())
    l.append(x)
    l.append(y)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = map(int, input().split())
ans = 0
route = [[0]*(n+1) for i in range(n+1)]

for i in range(m):
  f,t = map(int, input().split())
  route[f][t] += 1
  route[t][f] += 1

for i in range(1, n+1):
  print(sum(route[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:
from typing import List


def answer(n: int, m: int, ab_s: List[List[int]]) -> List[int]:
    roads = [0 for _ in range(n)]
    for ab in ab_s:
        a, b = ab
        roads[a - 1] += 1
        roads[b - 1] += 1

    return roads


def main():
    n, m = map(int, input().split())
    ab_s = [list(map(int, input().split())) for _ in range(m)]
    for i in answer(n, m, ab_s):
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
roads=[0 for _ in range(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())

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

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

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

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    for _ in range(m):
        a, b = i_map()
        num_list.append(a)
        num_list.append(b)

    num_counter = Counter(num_list)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
li = []
for _ in range(M):
  li += input().split()
for i in range(1,N+1):
  print(li.count(str(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
print(*L, sep = "\n")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main2():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp=[0]*n
    for number in numbers:
        for n in number:
            dp[n-1]+=1
    for ans in dp:
        print(ans)

def main():
    numbers=[]
    n,m = map(int,input().split())
    numbers=[list(map(int,input().split())) for _ in range(m)]
    dp={}
    for number in numbers:
        for n in number:
            if n not in dp:
                dp[n]=1
            else:
                dp[n]+=1
    print(dp)
    for i in range(1,len(dp)+1):
        print(dp[i])

if __name__=="__main__":
    main2()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
data = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    data[x].append(y)
    data[y].append(x)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
D=dict()
for i in range(n):
  D[i+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())
data = [input().split() for i in range(m)]
for i in range(1,n+1):
    count = 0
    for j in range(m):
        if int(data[j][0]) == i or int(data[j][1]) == i:
            count += 1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
N = list(range(1,n+1))
D = dict.fromkeys(N,0)

for _ in range(m):
  R = list(map(int,input().split()))
  for r in R:
    D[r] += 1

for d in D.values():
  print(d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

res = []

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

res = list(itertools.chain.from_iterable(res))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

N,M = map(int,readline().split())
ans = [0] * N

for i in range(M):
  ab = list(map(int,readline().split()))
  for a in ab:
    ans[a - 1] += 1
    
for a in ans:
  print(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
# B - Counting Roads
def main():
    import collections


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

    for _ in range(m):
        temp = list(input().split())
        cnt += temp
    else:
        ans = collections.Counter(cnt)
        for i in range(1, n+1):
            print(ans[str(i)])


if __name__ ==  "__main__":
    main()

Submission status: Accepted

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

for i in range(M):
    a, b = map(int,input().split())
    ab_list.append(a)
    ab_list.append(b)
    
for i in range(1, N + 1):
    print(ab_list.count(i))

Submission status: Accepted

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

for x in ans:
    print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

for v in graph[1:]:
    print(len(v))

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:

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans, adj
for adj in graph:
    ans.push_back(adj.size())

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

'''

    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:


import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans
for i in range(N):
    ans.push_back(graph[i].size())

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

'''
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans
for i in range(N):
    ans.push_back(graph[i].size())

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

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL
from libc.stdio cimport scanf
from libcpp.vector cimport vector as vec

ctypedef vec[vec[LL]] Graph
cdef LL i,j,k,_

cdef LL N,M
scanf('%lld %lld',&N,&M)

cdef Graph graph=Graph(N)

cdef LL a,b

# この問題をあえてグラフの構造を持つことで解く
for _ in range(M):
    scanf('%lld %lld',&a, &b)
    graph[a-1].push_back(b-1)
    graph[b-1].push_back(a-1)

cdef vec[LL] ans, adj
for adj in graph:
    ans.push_back(adj.size())

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

'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
import sys
import numpy as np
import collections as cl
import itertools as it
# import more_itertools as mit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000)

n, m = map(int, readline().split())
A = []
B = []
for _ in range(m):
    a, b = map(int, readline().split())
    A.append(a)
    B.append(b)
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())
L = []
for i in range(M):
  a, b = map(int, input().split())
  L.append(a)
  L.append(b)

for n in range(1, N+1):
  print(L.count(n))

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL

cdef extern int __builtin_popcount(unsigned int) nogil

import numpy as np

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち


cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


cdef read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)

# この問題をあえてグラフの構造を持つことで解く
from libcpp.vector cimport vector as vec

cdef LL N,M
N,M=ints()
AB=read_matrix(M,2)-1
cdef LL a,b

ctypedef vec[vec[LL]] Graph
cdef Graph graph=Graph(N)

for a,b in AB:
    graph[a].push_back(b)
    graph[b].push_back(a)

cdef vec[int] ans
for i in range(N):
    ans.push_back(graph[i].size())
print(*ans, sep='\n')
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
mycode = '''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

ctypedef long long LL

cdef extern int __builtin_popcount(unsigned int) nogil

import numpy as np

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち


cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


cdef read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)

# この問題をあえてグラフの構造を持つことで解く
from libcpp.vector cimport vector as vec

cdef LL N,M
N,M=ints()
AB=read_matrix(M,2)-1
cdef LL a,b

ctypedef vec[vec[LL]] Graph
cdef Graph graph=Graph(N)

for a,b in AB:
    graph[a].push_back(b)
    graph[b].push_back(a)

cdef vec[int] ans
for i in range(N):
    ans.push_back(graph[i].size())
print(*ans, sep='\\n')
'''

import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

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

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

Submission status: Accepted

Solution code:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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())
edge = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
print("\n".join(list(map(lambda x:str(len(x)), edge))))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
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+b).count(i+1))

Submission status: Accepted

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