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:
# Problem: https://atcoder.jp/contests/abc061/tasks/abc061_b
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(cityCount, roadCount, fromCity, toCity):
    result = [0]*(cityCount+1)
    roadRange = range(0, roadCount, +1)
    for j in roadRange:
        city = fromCity[j]
        result[city] = result[city] + 1
        city = toCity[j]
        result[city] = result[city] + 1
    # algorithm
    # print("RESULT {}".format(result[1:cityCount+1]))
    return result[1:cityCount+1]


if __name__ == "__main__":
    N, M = MI()
    fromCity = []
    toCity = []
    roadRange = range(0, M, +1)
    for _ in roadRange:
        tmp_i, tmp_j = MI()
        fromCity.append(tmp_i)
        toCity.append(tmp_j)
    solveList = solver(N, M, fromCity, toCity)
    # print("{}".format(solver()))
    for j in range(0, N, +1):
        print(solveList[j])

Submission status: Accepted

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

list = [input() for i in range(m)]

for i in range(m):
    ary = list[i].split()
    count_list[int(ary[0])-1] += 1
    count_list[int(ary[1])-1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
town = [0]*M*2
for i in range(M):
    town[i*2], town[i*2+1] = map(int, input().split())

for ans in range(1,N+1):
     print(town.count(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
road=[list(map(int,input().split())) for _ in range(M)]
result={i:0 for i in range(1, N+1)}
for i,j in road:
  result[i] += 1
  result[j] += 1
[print(result[i]) for i in range(1, N+1)]

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# In[25]:


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


# In[27]:


ans = [len(cities) for cities in mylist]
for x in ans:
    print(x)


# In[ ]:

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())

G = defaultdict(list)

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

for i in range(1, N + 1):
    l = G.get(i, None)
    if l is None:
        print(0)
    else:
        print(len(l))

Submission status: Accepted

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

memo = [0]*n

for i in range(m):
    memo[l[i][0]-1] += 1
    memo[l[i][1]-1] += 1

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

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

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,m = readInts()
ab = [0]*(n+1)
for i in range(m):
	a,b = readInts()
	ab[a]+=1
	ab[b]+=1

for i in range(1,n+1):
	print(ab[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())
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())
ab = [list(map(int, input().split())) for i in range(m)]
for j in range(n):
    ans = 0
    for k in range(m):
        if ab[k][0] == j + 1:
            ans += 1
        elif ab[k][1] == j + 1:
            ans += 1
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def pathnumber(N, M) : 
  path = [0] * (N + 1)
  for i in range(M) : 
    x, y = tuple(map(int, input().split()))
    path[x] += 1 
    path[y] += 1
  return path

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

path = pathnumber(N, M)

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

Submission status: Accepted

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

Submission status: Accepted

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

for j in range(a):
	print(c[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = [0] * (N + 1)
for _ in range(M):
    fr, to = map(int, input().split())
    ans[fr] += 1
    ans[to] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(n):
        ans.append(0)    

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

Submission status: Accepted

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

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

for i in road:
    print(i)

Submission status: Accepted

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

for i, j in li:
    ans_li[i-1] += 1
    ans_li[j-1] += 1

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

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc061/tasks/abc061_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(CITY_NUM, CITY_LIST):
    # result = ""
    resultList = [0] * CITY_NUM
    for j in range(0, len(CITY_LIST), +1):
        now_city = CITY_LIST[j]
        resultList[now_city-1] = resultList[now_city-1]+1
    # for j in range(0, CITY_NUM, +1):
        # print("CITY:{} ROAD:{}".format(j, resultList[j]))
    resultListStr = [str(j) for j in resultList]
    return '\n'.join(resultListStr)
    # print("{}".format(strReturn))
    # return result


if __name__ == "__main__":
    N, M = MI()
    ROAD_ENUMERATION_LIST = []
    for j in range(0, M, +1):
        from_tmp, to_tmp = MI()
        ROAD_ENUMERATION_LIST.append(from_tmp)
        ROAD_ENUMERATION_LIST.append(to_tmp)
    print("{}".format(solver(N, ROAD_ENUMERATION_LIST)))

Submission status: Accepted

Solution code:
def counting_sort(array,city,road):
    bucket = [0] * city

    for i in range(road):
        for j in range(2):
            bucket[ (array[i][j] - 1) ] += 1

    return bucket

def main():
    n,m = map(int, input().split())
    way = [list(map(int,input().split())) for _ in range(m)]
    ans_list = counting_sort(way, n, m)
    for k in range(n):
        print( ans_list[k] )

main()

Submission status: Accepted

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

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

X = []
for i in range(m):
  X.append(R[i][0])
  X.append(R[i][1])
  
for i in range(1,n+1):
  print(X.count(i))

Submission status: Accepted

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

Submission status: Accepted

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

for j in result:
    print(j)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)

Submission status: Accepted

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

grid = []
for i in range(m):
  array = list(map(int, input().strip().split()))
  grid.append(array)
  
for i in range(1,n+1):
  road = 0
  for j in grid:
    if i in j:
      road +=1
  print(road)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

array = np.zeros(n)

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

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:
from collections import defaultdict
N, M = list(map(int, input().split()))
count = defaultdict(int)
for _ in range(M):
    a, b = list(map(int, input().split()))
    count[a] += 1
    count[b] += 1

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

Submission status: Accepted

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

roads = [0]*N
for i 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())
l = []

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

ans = [0]*N

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
list1=[]
ans=[]
for i in range(m):
    a,b=input().split()
    list1.append(a)
    list1.append(b)
for i in range(n):
    ans.append(list1.count(str(i+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(i) for i in ans]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
List=[]
for i in range(m):
    road=list(map(int,input().split()))
    List.append(road)
    road=[road[1],road[0]]
    List.append(road)
ans=0
for i in range(1,n+1):
    for j in range(len(List)):
        if i==List[j][0]:
            ans+=1
    print(ans)
    ans=0

Submission status: Accepted

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

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

for a in A:
	print(a)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
res = {}
for i in range(1,N+1):
    res[i] = 0
for _ in range(M):
    a,b = map(int,input().split())
    res[a] += 1
    res[b] += 1
for key in sorted(res.keys()):
    print(res[key])

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc061/tasks/abc061_b
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(cityNumber, roadNumber):
    result = [0] * cityNumber
    fromList = []
    toList = []
    for _ in range(0, roadNumber, +1):
        tmp_f, tmp_t = MI()
        fromList.append(tmp_f -1)
        toList.append(tmp_t - 1)
    # print("from_LIST:{}".format(fromList))
    # print("to_LIST{}".format(toList))
    city_Count_List = [0] * cityNumber
    for j in range(0,roadNumber,+1):
        city_Count_List[fromList[j]] = city_Count_List[fromList[j]] + 1
        city_Count_List[toList[j]] = city_Count_List[toList[j]] + 1
    result = city_Count_List
    return result
if __name__ == "__main__":
    N, M = MI()
    answerList = solver(N, M)
    for j in range(0, N, +1):
        print("{}".format(answerList[j]))

Submission status: Accepted

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

Submission status: Accepted

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

road=[]
for i in range(n):
  road.append([])

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

Submission status: Accepted

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

Submission status: Accepted

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

for a, b in ab:
    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())
ab = [map(int, input().split()) for _ in range(M)]
a, b = [list(i) for i in zip(*ab)]

path = [0]*N

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

for v in path:
    print(v)

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 i in range(n):
    print(A[i])

Submission status: Accepted

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

d = dict.fromkeys(range(1, N+1), 0)

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

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

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(N):
    print(d[i+1])

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:
def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(m)]
    res = [0] * n
    for i in ab:
        res[i[0] - 1] += 1
        res[i[1] - 1] += 1
    for i in res:
        print(i)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

[print(x) for x in num_c]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for road in roads:
    print(road)

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    adj = [[] for _ in range(n)]

    for _ in range(m):
        a, b = mi_0()
        adj[a].append(b)
        adj[b].append(a)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

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