Problem:


Score : 200 points

Problem Statement

There are N cities and M roads.
The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.
There may be more than one road that connects the same pair of two cities.
For each city, how many roads are connected to the city?

Constraints

2≤N,M≤50

1≤a_i,b_i≤N

a_i ≠ b_i

All input values are integers.

Input

Input is given from Standard Input in the following format:  

N M
a_1 b_1
:  
a_M b_M

Output

Print the answer in N lines.
In the i-th line (1≤i≤N), print the number of roads connected to city i.

Sample Input 1

4 3
1 2
2 3
1 4

Sample Output 1

2
2
1
1

City 1 is connected to the 1-st and 3-rd roads.

City 2 is connected to the 1-st and 2-nd roads.

City 3 is connected to the 2-nd road.

City 4 is connected to the 3-rd road.

Sample Input 2

2 5
1 2
2 1
1 2
2 1
1 2

Sample Output 2

5
5

Sample Input 3

8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8

Sample Output 3

3
3
2
2
2
1
1
2



Sample input:
4 3
1 2
2 3
1 4


Sample output:
2
2
1
1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
L= [list(map(int, input().split())) for i in range(M)]
for i in range(1, N+1):
    C=0
    for j in range(M):
        if i in L[j]:
            C += 1
    print(C)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ablist = [tuple(map(int, input().split())) for _ in range(M)]
city_list = [0] * N

for a, b in ablist:
    city_list[a - 1] += 1
    city_list[b - 1] += 1

for city in city_list:
    print(city)

Submission status: Accepted

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

for _ in range(M):
    ai, bi = input().split()
    a.append(ai)
    b.append(bi)

for i in range(1, N + 1):
    print(a.count(str(i)) + b.count(str(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())

list = a + b

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

Submission status: Accepted

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

res = []
for _ in range(m):
    res += [int(x) for x in input().split()]

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

Submission status: Accepted

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

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)
    List.append(b)
for j in range(N):
    print(List.count(j+1))

Submission status: Accepted

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

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

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)

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:
import collections
N,M = map(int,input().split())
mat = [list(map(int,input().split())) for i in range(M)]
tmp = []
for i in range(M):
    tmp = tmp + mat[i]
ans = collections.Counter(tmp)
for j in range(N):
    print(ans[j+1])

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 _ in range(m):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for _ans in ans:
    print(_ans)

Submission status: Accepted

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

Submission status: Accepted

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

path_cnt = [0] * (N+1)

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

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

Submission status: Accepted

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

def countList(lst, x):
    count = 0
    for i in range(len(lst)):
        if x in lst[i]:
            count += 1
    return count

for i in range(1, n + 1):
    print(countList(a_b, i))

Submission status: Accepted

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

    
ans=[]
for i in range(n):
    ans.append(s1.count(i+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):
    l+=list(map(int,input().split()))
for j in range(n):
    print(l.count(j+1))

Submission status: Accepted

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

for i in range(N):
  num = i+1
  count = 0
  for a, b in paths:
    if a == num or b == num:
      count += 1
  print(count)

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

Submission status: Accepted

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

for r in road:
    print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ABC061 B - Counting Roads
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N,M = nm()
G = [[] for _ in range(N)]

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

for g in G:
    print(len(g))

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())
  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())
from collections import defaultdict
d = defaultdict(int)
for i 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())
l = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    l[a - 1].append(b)
    l[b - 1].append(a)
for i in range(n):
    print(len(l[i]))

Submission status: Accepted

Solution code:
#提出コードみました
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
list = {i:0 for i in range(1,n+1)}
for i in ab:
  list[i[0]] += 1
  list[i[1]] += 1
for j in list.values():
  print(j)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(m)]
city = {}
city = {i:0 for i in range(1, n+1)}
for point in points:
  city[point[0]] += 1
  city[point[1]] += 1
for i in city.values():
  print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

for c in range(M):
    R[ab[c][0]-1] += 1
    R[ab[c][1]-1] += 1
for c in range(N):
    print(R[c])

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
list=[[] for j in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  list[a-1]+="Y"
  list[b-1]+="Y"
for i in range(N):
  print(len(list[i]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

for _ in c:
    print(_)

Submission status: Accepted

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

for c in city:
    print(c)

Submission status: Accepted

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

roads=[[str(s) for s in input().split()] for m in range(M)]

ans={}

for m in range(M):
  for road in roads[m]:
    if road in ans:
      ans[road]+=1
    else:
      ans[road]=1

for n in range(N):
  if str(n+1) in ans:
    print(ans[str(n+1)])
  else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections as coll
n,m=map(int,input().split())
road=coll.defaultdict(list)
for _ in range(m):
    a,b=map(int,input().split())
    road[a].append(b)
    road[b].append(a)
for i in range(1,n+1): print(len(road[i]))

Submission status: Accepted

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

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())
    a -= 1
    b -= 1
    edges[a] += 1
    edges[b] += 1

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

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

Submission status: Accepted

Solution code:
import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a);l.append(b)
l.sort()
for j in range(1,n+1):
    print(l.count(j))

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 road in roads:
    print(road)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
N,M=map(int,input().split())
d=Counter((' '.join([input() for m in range(M)])).split(' '))
for n in range(N):
    print(d[str(n+1)])

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    d = collections.defaultdict(list)
    n, m = list(map(int, input().rstrip('\n').split()))
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        d[a] += [1]
        d[b] += [1]
    for i in range(1, n + 1):
        print(sum(d[i]))


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

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

for i in range(1, n+1):
    t = [x for x, y in enumerate(s) if y == i]
    t = len(t)
    u.append(t)

for i in u:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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 j in range(1,n+1):
    print(a.count(j))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
ab = [input().split() for _ in range(M)]
ab = sum(ab, [])
c = Counter(ab)
for i in range(1, N+1):
    print(c[str(i)])

Submission status: Accepted

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

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

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

for i in l:
    l2[i[0] - 1][i[1] - 1] += 1
    l2[i[1] - 1][i[0] - 1] += 1

for i in l2:
    print(sum(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
n, m = map(int, input().split())
counter = collections.Counter()
for _ in range(m):
    a, b = map(int, input().split())
    counter[a] += 1
    counter[b] += 1
for i in range(n):
    print(counter[i + 1])

Submission status: Accepted

Solution code:
#N都市にM道路
n, m = map(int, input().split())
cities = [0] * n
for i in range(m):
  a, b = map(int, input().split())
  cities[a-1] +=1
  cities[b-1] +=1
for i in cities:
  print(i)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
li = [input().split() for i in range(b)]
for i in range(b):
    li[i] = [int(x) for x in li[i]]
li2 = []
for i in range(b):
    li2.append(li[i][0])
    li2.append(li[i][1])

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

Submission status: Accepted

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

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

for r in R:
  print(r)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n, m = map(int, input().split())
    xy = list(list(map(int, input().split())) for _ in range(m))
    ans = [0] * n
    for x, y in xy:
        ans[x - 1] += 1
        ans[y - 1] += 1
    for a in ans:
        print(a)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    for j in range(2):
        t.append(s[i][j])


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

Submission status: Accepted

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

g = [[0] * (N+1) for _ in range(N+1)]

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

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

Submission status: Accepted

Solution code:
N, M = tuple(map(int, input().split()))
A, B = [], []
for _ in range(M):
    a, b = tuple(map(int, input().split()))
    A.append(a)
    B.append(b)
roads = {i: 0 for i in range(1, N+1)}
for a, b in zip(A, B):
    roads[a] += 1
    roads[b] += 1
for key, val in sorted(roads.items()):
    print(val)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - Counting Roads
N, M = map(int,input().split())
city = [list(map(int, input().split())) for i in range(M)]
road = [0]*N

for i in range(N):
    count = 0
    for j in range(M):
        if i+1 == city[j][0]:
            count += 1
        else:
            pass
        if i+1 == city[j][1]:
            count += 1
        else:
            pass
    road[i] = count
for k in range(N):
    print(road[k])

Submission status: Accepted

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

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

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

for i in sorted(roads):
    print(len(roads[i]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n,m=map(int,input().split(' '))
    road = [[i for i in list(map(int,input().split(' ')))] for i in range(m)]
    ans = [0]*n
    for i,j in road:
        ans[i-1] += 1
        ans[j-1] += 1
    for i in ans:
        print(i)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M,*A=map(int,open(0).read().split());l=[0]*N
for a in A:l[a-1]+=1
for r in l:print(r)

Submission status: Accepted

Solution code:
N,M,*A=map(int,open(0).read().split());l=[0]*N
for a,b in zip(A[::2],A[1::2]):l[a-1]+=1;l[b-1]+=1
for r in l:print(r)

Submission status: Accepted

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

Submission status: Accepted

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

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

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


if __name__ == "__main__":
    main()

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 i in range(1, n+1):
  cnt = 0
  for j, k in zip(A,B):
    if i == j or i == k:
      cnt += 1
  print(cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
cities = []
for i in range(n):
    cities.append(0)
for i in range(m):
    x = list(input().split())
    for j in range(2):
        cities[int(x[j]) - 1] += 1
for i in range(len(cities)):
    print(cities[i])

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int, input().split())

a = np.zeros(M)
b = np.zeros(M)
for i in range(M):
  a[i],b[i] = map(int, input().split())
  
for i in range(1,N+1):
  print((a==i).sum() + (b==i).sum())

Submission status: Accepted

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

roads = [[] for _ in range(n)]
for _ in range(m):
    f, t = list(map(int, input().split()))
    roads[f-1].append(t-1)
    roads[t-1].append(f-1)
for i in range(n):
    print(len(roads[i]))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
import itertools
A=[list(map(int,input().split())) for i in range(M)]
#print(A)
B=list(itertools.chain.from_iterable(A))
#print(B)
 
for a in range(1,N+1):
    print(B.count(a))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
import itertools
A=[list(map(int,input().split())) for i in range(M)]
B=list(itertools.chain.from_iterable(A))

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = (int(x) for x in input().split())

list = []
for i in range(0,M):
    a,b = (int(x) for x in input().split())
    list.append(a)
    list.append(b)

for j in range(1,N+1):
    print(list.count(j))

Submission status: Accepted

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

for i in range(1,n+1):
    ans=0
    for j in range(m):
        if ab[j][0]==i or ab[j][1]==i:
            ans+=1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = list(map(int, input().split()))
arr = [list(map(int, input().split())) for _ in range(m)]
from collections import defaultdict
city = defaultdict(list)

for road in arr:
  city[road[0]].append(road[1])
  city[road[1]].append(road[0])

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ARC 061 A

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

  arr = [0] * (n+1)

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

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


if __name__ == "__main__":
    resolve()

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):
    r = road.count(i)
    print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def main():


   N , M= map(int,input().split())
   tmpList = [ list(map(int,input().split())) for _ in range(M)]
   roadList = [ j for i in tmpList for j in i]

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







if __name__== "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
arr = [map(int, input().split()) for _ in range(m)]
d = {i:0 for i in range(1, n+1)}
for a, b in arr:
    d[a] += 1
    d[b] += 1
for v in sorted(d.items(), key=lambda x: x[0]):
    print(v[1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) 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:
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:
def resolve():
    n,m=map(int,input().split())
    edges=[0 for _ in range(n)]
    for _ in range(m):
        a,b=map(lambda x:int(x)-1,input().split())
        edges[a]+=1
        edges[b]+=1
    print(*edges,sep='\n')
resolve()

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:
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, m = na()
d = [0] * n
for i in range(m):
    a, b = na()
    d[a - 1] += 1
    d[b - 1] += 1
for i in range(n):
    print(d[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

L = [0 for i in range(N)]

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

for l in L:
  print(l)

Submission status: Accepted

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

s = [0]*N

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