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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

#print(R)
c = collections.Counter(sum(R,[]))
keys=c.keys()
for n in range(1,N+1):
  if n not in keys:
    print(0)
  else:
    print(c[n])

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

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])
#print(count)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
roads=[]
for i in range(m):
  roads.append(input().split())
count=0
for j in range(1,n+1):
  for k in range(m):
    if int(roads[k][0])==j or int(roads[k][1])==j:
      count+=1
      #print('road')
  print(count)
  count=0

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from functools import reduce

reduce(lambda a, b: a + b, [[1,2,3],[4,5,6],[7,8,9]])  #=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

abflatten = sum(ab, [])

# print(abflatten)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
c,r=map(int,input().split())

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

for j in range(1,c+1):
    print(l.count(j))

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)
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())
U = [[] for _ in range(N + 1)]

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

for i in range(1, N + 1):
    print(len(U[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(1,N+1):
    print(a.count(i) + b.count(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)
l.sort()
count = 1
for i in range(n):
    print(l.count(i+1))

Submission status: Accepted

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

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

for r in c:
  print(r)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a <= c <= b:
        print("Yes")
        return
    print("No")
    return

#B
def B():
    n, m = LI()
    e = defaultdict(int)
    for i in range(1, n + 1): e[i] = 0
    for i in range(m):
        a, b = LI()
        e[a] += 1
        e[b] += 1
    for i in e.values():
        print(i)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
def main():
    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)


main()

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(n):
        print(sum(roads, []).count(i + 1))


if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l+=list(map(int,input().split()))
print(*[l.count(i+1) for i in range(n)],sep='\n')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range (n):
    cnt=0
    for j in range(m*2):
        if x[j]==i+1:
            cnt = cnt+1
    print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    num, k = map(int, input().split())
    data = defaultdict(int)
    for i in range(k):
        a, b = map(int, input().split())
        data[a] += 1
        data[b] += 1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(a):
  print(d[i])

Submission status: Accepted

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

Submission status: Accepted

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

for x in lst[1:]:
    print(x)

Submission status: Accepted

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

for i in lst:
    print (i)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main(N,M,A,B):
    ct = [0]*N
    for i in range(M):
        ct[A[i]-1] += 1
        ct[B[i]-1] += 1
    for i in range(N):
        print(ct[i])
    
if __name__ == '__main__':
    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)
    
    main(N,M,A,B)

Submission status: Accepted

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

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

Submission status: Accepted

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

A, B = [], []
for m in range(M):
    line = input().split()
    A.append(int(line[0]))
    B.append(int(line[1]))

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

Submission status: Accepted

Solution code:
from collections import Counter

n, m = map(int, input().split(" "))
r = zip(*[list(map(int, input().split(" "))) for i in range(m)])
r = list(r)
c1 = dict(Counter(r[0]).most_common())
c2 = dict(Counter(r[1]).most_common())
for i in range(1, n + 1):
    print((c1[i] if i in c1 else 0) + (c2[i] if i in c2 else 0))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [tuple(map(typ, input().split())) if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, M = read_h()
    roads = read_v(M, m=2)
    cnt = [0] * N

    for a, b in roads:
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for c in cnt:
        print(c)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = [list(map(int,input().split())) for i in range(a[1])]
c = []

for i in range(a[0]):
  d = []
  for j in range(a[1]):
    d.append(b[j].count(i+1))
  else:
    c.append(sum(d))
else:
  for i in range(a[0]):
    print(c[i])

Submission status: Accepted

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

for cnt in edge:
    print(cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
x =[]
y =[]
for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
d ={}
for i in range(1,n+1):
    d[i]=0

for i in range(m):
    d[x[i]] += 1
    d[y[i]] += 1

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

Submission status: Accepted

Solution code:
import numpy as np
row = input().split()
N = int(row[0])
M = int(row[1])
row2 = [input().split() for i in range(M)]
f = np.vectorize(int)
a = f(row2)
for i in range(1, N+1):
    count = 0
    for j in range(M):
        for k in range(2):
            if i == a[j][k]:
                count += 1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l=[]
for i in range(m):
    l.extend(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())
lst = []
for i in range(m):
    a,b = map(int,input().split())
    lst.append(a)
    lst.append(b)

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

Submission status: Accepted

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

ret=[0 for _ in range(n)]
for i in range(n):  
  for ai in a:
    if i+1 in ai:
      ret[i]+=1
for i in ret:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# B問題
N, M = map(int, input().split())
ab = []
for i in range(M):
    ab.append(list(map(int, input().split())))
ans = []
for i in range(N):
    tmp = 0
    for k in range(M):
        if i+1 in ab[k]:
            tmp += 1
    ans.append(tmp)
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
ans = [0] * N
for i in data:
    ans[i[0]-1] += 1
    ans[i[1]-1] += 1
for j in ans:
    print(j)

Submission status: Accepted

Solution code:
N, M = [int(s) for s in input().split()]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

for i in range(n):
    print(sum(city[i]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    ret = [0] * N
    for i in range(M):
        ret[a[i] - 1] += 1
        ret[b[i] - 1] += 1
    for r in ret:
        print(r)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(n):
    print(sum(r[i]))

Submission status: Accepted

Solution code:
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
roads = defaultdict(list)

for i in range(M):
    a, b = nl()
    roads[a].append(b)
    roads[b].append(a)

for i in range(N):
    if i+1 in roads:
        print(len(roads[i+1]))
    else:
        print(0)

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
d = {}
for i in range(1,N+1):
    d[i] = 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:
def abc():
    n, m = map(int, input().split())
    d = {}
    for i in range(m):
        a, b = map(int, input().split())
        d[a] = d.get(a, 0) + 1
        d[b] = d.get(b, 0) + 1
    for i in range(1, n+1):
        print(d.get(i, 0))


abc()

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
E = defaultdict(list)
for _ 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())

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    ans=0
    for j in range(m):
        if roads[j][0]==i+1:
            ans+=1
        elif roads[j][1]==i+1:
            ans+=1
    print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
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 bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


# S = sys.stdin.readline().rstrip()
# if len(S) == len(set(list(S))):
#     print('yes')
# else:
#     print('no')


N, M = list(map(int, sys.stdin.readline().split()))
A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

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

Submission status: Accepted

Solution code:
city_num, road_num = tuple(int(i) for i in input().split(" "))
city_road_list = [0 for i in range(city_num)]
for i in range(road_num):
    city_1, city_2 = tuple(int(i) for i in input().split(" "))
    city_road_list[city_1 - 1] += 1
    city_road_list[city_2 - 1] += 1
for i in city_road_list:
    print(i)

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for _ in range(m):
    ans += list(input().split())

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

Submission status: Accepted

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

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())
from collections import defaultdict
dic = defaultdict(lambda: 0)
for i in range(m):
    a, b = [int(j) for j in input().split()]
    dic[int(a)] += 1
    dic[int(b)] += 1

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

Submission status: Accepted

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

deg = [0] * (N+1)

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

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

Submission status: Accepted

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

for i in ab:
    print(a.count(i) + b.count(i))

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

Submission status: Accepted

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

for e in E[1:]:
    print(len(e))

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split(' ')))
road = []
for i in range(m):
  x,y =(list(map(int,input().split(' '))))
  road.append(x)
  road.append(y)

ans = list(set(road))
ans.sort()
for i in range(1,n+1):
  print(road.count(i))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
li = []
for i in range(m):
    li.append(list(map(int,input().split())))
cnt = []    #都市から伸びる道路数
for i in range(n):
    num = 0 #都市iの道路数
    for j in range(m):
        if li[j][0] == i+1 or li[j][1] == i+1:
            num += 1
    cnt.append(num)
for i in cnt:
    print(i)

Submission status: Accepted

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

way=[]

for i in range(n):
    way.append(list(map(int,input().split())))

city=[]
for j in range(1,m+1):
    city.append(j)

#print(way)
#print(city)

for k in city:
    cnt=0
    for l in way:
        for m in range(len(l)):
            if k==l[m]:
                cnt+=1
    print(cnt)

Submission status: Accepted

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

ans=[0]*(N+1)
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())
cities = [list(map(int, input().split())) for _ in range(M)]

roads = [0] * N
for city in cities:
  roads[city[0] - 1] += 1
  roads[city[1] - 1] += 1

for road in roads:
  print(road)

Submission status: Accepted

Solution code:
# input
n, k = map(int, input().split())
o = []
for i in range(k):
    t = list(map(int, input().split()))
    o += t
# calc
for i in range(1, n+1):
    print(o.count(i))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

a,b = ([0]*m,[0]*m)

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

from collections import defaultdict

d = defaultdict(int)

for j in a:
    d[j] +=1
for k in b:
    d[k] +=1

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
l = []
for _ 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:
# -*- coding: utf-8 -*-

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

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

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

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

for i in ar:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
bri_join = [[i for i in map(int,input().split())] for j in range(m)]
ans = {} 
for i in range(n):
    ans[i+1] = 0 
    for j in range(m):
        if i+1 in bri_join[j]:
            ans[i+1] += 1
    print(ans[i+1])

Submission status: Accepted

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

import itertools
import collections
import bisect

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


for i in range(1,N+1):
    road = 0
    for a,b in ab:
        if a == i:
            road += 1
        if b == i:
            road += 1
    print(road)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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(" "))
ab = [list(map(int,input().split(" "))) for i in range(M)]
#print(ab)
ans = [0 for i in range(N+1)]
for i in range(M):
    ans[ab[i][0]]+=1
    ans[ab[i][1]]+=1
    #print(ab[i][0])
    #print(ab[i][1])
for i in range(1,len(ans)):
    print(ans[i])