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())
lis = [0]*m
li = [0]*m
ans = [0]*n
for i in range(m):
    lis[i],li[i] = map(int,input().split())
for i in range(m):
    ans[lis[i]-1] += 1
    ans[li[i]-1] += 1
for t in range(n):print(ans[t])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=[sorted(list(map(int,input().split()))) for i in range(m)]
a=[]
for i in range(m):
    a.append(s[i][0])
    a.append(s[i][1])
sum=0
for i in range(1,n+1):
    for j in range(2*m):
        if i==a[j]:
            sum+=1
    print(sum)
    sum=0

Submission status: Accepted

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

road=[0for i in range(N)]
for i in range(M):
    road[ai[i]-1]+=1
    road[bi[i]-1]+=1
for i in range(N):
    print(road[i])

Submission status: Accepted

Solution code:
def solve():
    path_dict = {}
    N, M = list(map(int, input().split(" ")))
    for i in range(M):
        a, b = list(map(int, input().split(" ")))
        if a in path_dict.keys():
            path_dict[a] += 1
        else:
            path_dict[a] = 1
        if b in path_dict.keys():
            path_dict[b] += 1
        else:
            path_dict[b] = 1
    for i in range(1,N+1):
        if i in path_dict.keys():
            print(path_dict[i])
        else:
            print(0)
    
solve()

Submission status: Accepted

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

Submission status: Accepted

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

d = [0 for _ in range(1, 55)]
for _ in range(0, m):
    a, b = map(int, input().split())

    d[a] += 1
    d[b] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

T=[0]*N
for i in range(M):
    T[S[i][0]-1]+=1
for i in range(M):
    T[S[i][1]-1]+=1

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

Submission status: Accepted

Solution code:

from collections import Counter

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=eval(",".join(input().replace(" ",",")for i in [0]*m))
for i in range(n):
    print(a.count(i+1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Ans = 0

for k in range(1,N+1):
	for i in range(0,M):
		for j in range(0,2):
			if lis[i][j] == k:
				Ans += 1
	print(Ans)
	Ans = 0

Submission status: Accepted

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

    for road in roads:
        print(road)


solve()

Submission status: Accepted

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

road = []
for i in range(M):
    for j in range(2):
        road.append(s[i][j])


for k in range(N):
    ans = 0
    ans = road.count(k+1)
    print(ans)

Submission status: Accepted

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

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

for i in ans:
  print(i)

Submission status: Accepted

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

N,M=list( int(i) for i in input().split() )
counter=[0]*N

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

for i in range(0, N):
    print(counter[i])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
num = [int(x) for x in input().split()]

array = []
for i in range(num[1]):
    array.append([int(x) for x in input().split()])

res = [0 for x in range(num[0])]

for j in array:
    res[j[0]-1] = res[j[0]-1] +1
    res[j[1]-1] = res[j[1]-1] +1

for k in res:
    print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://abc061.contest.atcoder.jp/tasks/abc061_b

"""
import sys
from sys import stdin
input = stdin.readline


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

    roads = [0] * (N+1)
    for _ in range(M):
        f, t = map(int, input().split())
        roads[f] += 1
        roads[t] += 1

    print('\n'.join(map(str, roads[1:])))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n,m=map(int,input().split())
c=dict()
ret=[]
for i in range(m):
    ret+=map(int,input().split())<<ap>>list

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

Submission status: Accepted

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

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())
    a -= 1
    b -= 1
    L[a].append(b)
    L[b].append(a)
for i in range(N):
    print(len(L[i]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, raw_input().split())
cnt = [0]*N
for loop in xrange(M):
    a, b = map(int, raw_input().split())
    cnt[a - 1] += 1
    cnt[b - 1] += 1
for i in cnt:
    print i

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(x[0]):
    print(b.count('{}'.format(i+1)))

Submission status: Accepted

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

for r in ret:
    print(r)

Submission status: Accepted

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

AB = [tuple(map(int,input().split())) for _ in range(M)]
tree = [[] for _ in range(N+1)]

for ab in AB:
    tree[ab[0]].append([ab[1]])
    tree[ab[1]].append([ab[0]])

tree.pop(0)
for t in tree:
    print(len(t))

Submission status: Accepted

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

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

print('\n'.join(map(str, num)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N, M = map(int, input().split())
dp = makelist(N+1, N+1)

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

for i in range(1, N+1):
    ans = 0
    for k in range(1, N+1):
        if k != i:
            ans += dp[i][k]
    print(ans)

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


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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

c_n=[int(i) for k in range(M) for i in input().split()]

d_n=[c_n.count(i) for i in range(1,N+1)]

for i in range(N):
    print(d_n[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 j in range(1, n+1):
	print(l.count(j))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



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

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

if __name__ == "__main__": main()

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

count = [0] * N
for i in range(M):
    for j in range(N):
        if a[i] == (j+1) or b[i] == (j+1):
            count[j] += 1

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

Submission status: Accepted

Solution code:
import collections


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

for i in range(n):
    li.append(i+1)


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

c = collections.Counter(li)

for k, v in sorted(c.items(), key=lambda x: x[0]):
        print(v-1)

Submission status: Accepted

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

graph = [list() for _ in range(N+1)]

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

Submission status: Accepted

Solution code:
def main():
    N, M = list(map(int, input().strip().split()))
    load_counts = [0 for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, input().strip().split()))
        load_counts[a - 1] += 1
        load_counts[b - 1] += 1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    d = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)
    for i in range(1, N + 1):
        print(len(d[i]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = [0 for i in range(0,n)]

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

for i in range(0, n):
    print(count[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 ans in l:
    print(ans)

Submission status: Accepted

Solution code:
# Counting Roads

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

b = []
for s in a:
    b.extend(s)
for i in range (n):
    print(b.count(i+1))

Submission status: Accepted

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

for c in count:
    print(c)

Submission status: Accepted

Solution code:
import sys

N, M = (int(i) for i in raw_input().split())
ab_list = [[int(i) for i in raw_input().split()] for i in range(M)]

road_list = [0] * N
for ab in ab_list:
    a, b = ab
    road_list[a-1] += 1
    road_list[b-1] += 1

for road_num in road_list:
    print road_num

Submission status: Accepted

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

Submission status: Accepted

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

arr = []

for i in range(M):
    arr.append(map(int, raw_input().split()))

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

for i in range(M):
    tempa = arr[i][0] - 1
    tempb = arr[i][1] - 1

    ans[tempa] += 1
    ans[tempb] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

N, M = map(int, input().split())
l = [0] * N

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

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

Submission status: Accepted

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

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('b1.in')
from collections import Counter

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

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

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('b1.in')

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

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

res = [0] * n
for a, b in roads:
    res[b - 1] += 1
    res[a - 1] += 1
for r in res:
    print(r)

Submission status: Accepted

Solution code:
N,M = [int(i) for i in input().split(" ")]
road = [0]*(N+1)
for i in range(M):
    a_i,b_i = [int(j) for j in input().split(" ")]
    road[a_i] += 1
    road[b_i] += 1
for i in range(1,N+1):
    print(road[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
info = list()
for i in range(0, n + 1):
    info.append(0)
for i in range(0, m):
    a, b = map(int, input().split())
    info[a] = info[a] + 1
    info[b] = info[b] + 1
for i, value in enumerate(info):
    if i is not 0:
        print(value)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
lis=list()
for var in range(1,M+1):
    a,b=map(int,input().split())
    lis.append(a)
    lis.append(b)

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

Submission status: Accepted

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

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,raw_input().split())

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

for i in r:
    print i

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

x = list(map(int, input().split()))
a=[input() for i in range(x[1])]
count=[]

for i in range(0,x[0]+2):
    count=count+[[0,i]]

for i in a:
    i=list(map(int, i.split()))
    count[i[0]][0]+=1
    count[i[1]][0]+=1
   
  
for i in range (1,x[0]+1):
    print(count[i][0])

Submission status: Accepted

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

ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(m)]

result_list = [[] for i in range(n)]

for ab in ab_list:
    result_list[ab[0]].append(ab[1])
    result_list[ab[1]].append(ab[0])


for result in result_list:
    print(len(result))

Submission status: Accepted

Solution code:
a = input().split()
city = int(a[0])
road = int(a[1])

x = []
for i in range(road):
    b = input().split()
    x.append(int(b[0]))
    x.append(int(b[1]))

for i in range(city):
    count = 0
    for j in x:
        if i+1 == j:
            count += 1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

n,m = map(int, input().split())
city = [0] * (n + 1)

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

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

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

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

for s in street:
    print(s)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(M)]
cnt = [0 for i in range(N)]
for road in roads:
    for r in road:
        cnt[r-1] += 1

for c in cnt:
    print(c)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
counts = [0] * (n + 1)
for _ in range(m):
    a, b = map(int, input().split())
    counts[a] += 1
    counts[b] += 1
print('\n'.join(map(str, counts[1:])))

Submission status: Accepted

Solution code:
def solve():
  ar = raw_input().split(' ')
  N = int(ar[0])
  M = int(ar[1])
  counts = [0 for i in range(N)]
  for i in range(M):
    #print counts
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    counts[a-1] = counts[a-1] + 1
    counts[b-1] = counts[b-1] + 1
  #print counts
  print '\n'.join(str(c) for c in counts)

if __name__ == '__main__' :
  solve()

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

Submission status: Accepted

Solution code:
nm = [int(n) for n in input().split()]
c = [0] * nm[0]
for i in range(nm[1]):
    ab = [int(num) for num in input().split()]
    c[ab[0] - 1] += 1
    c[ab[1] - 1] += 1
for i in range(nm[0]):
    print(c[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
nums = []
for i in range(m) :
    for val in map(int, input().split()):
        nums.append(val-1)
for i in range(n):
    print(nums.count(i))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
size ,times = map(int, input().split())
road = [0 for i in range(size)]

for i in range(times):
    t1,t2 = map(int,input().split())
    road[t1-1] += 1
    road[t2-1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#/Users/Shuhei_Nakano/Desktop/sprogram/PCC

N, M = map(int, input().split())
a=[];
b=[];

for i in range(M):
    c, d= map(int, input().split())
    a.append(c)
    b.append(d)
f=[]
f2=[]
for i in range(N):
    f=[]
    for j in range(M):
        if (a[j]==i+1):
            f.append(j+1)
        if (b[j]==i+1):
            f.append(j+1)
            f=list(set(f))
    dd=len(f)
    f2.append(dd)

#print(f2)
for i in f2:
    print(i)

Submission status: Accepted

Solution code:
""" abc061_b:B - Counting Roads """
L = input().rstrip().split(' ')
N = int(L[0])
M = int(L[1])

ANS = []
for i in range(N):
    ANS.append(0)

for i in range(M):
    L = input().rstrip().split(' ')
    ANS[int(L[0])-1] += 1
    ANS[int(L[1])-1] += 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, M = ILI()
    edges = IAI(M)
    return (N, M, edges)


def solve(N, M, edges):
    ans = [0] * N
    for edge in edges:
        a, b = map(lambda x: x - 1, edge)
        ans[a] += 1
        ans[b] += 1
    
    return ans


def main():
    params = read()
    ans = solve(*params)
    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# N,Mの把握
l = list(map(int, input().split()))
N = l[0]
M = l[1]

#list(map(str, input().split()))をM回くりかえし、１つのリストにまとめる。

c = []
for i in range(M):
	c = c + list(map(int, input().split()))

# リストを指定の番号で検索して、項目数を返す関数
def r(x):
	y = str(c.count(x))
	return y

#都市番号1からNまでリストを検索し、出力
dic = {}
for i in range(1,N+1):
	print(r(i))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    from numpy import zeros
    N, M = map(int, input().split())
    city = zeros(2*M, dtype='int32')
    for i in range(M):
        city[2*i:2*i+2] = list(map(int, input().split()))
    ans = zeros(N+1, dtype='int32')
    for j in city:
        ans[j] += 1
    for i in range(1, N+1):
        print(ans[i])

Submission status: Accepted

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

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

for i in road:
    print(i)

Submission status: Accepted

Solution code:
b = input().split(" ")
num = [0 for i in range(int(b[0]))] 
for i in range(int(b[1])):
    a = input().split(" ")
    num[int(a[0])-1] = num[int(a[0])-1]+1
    num[int(a[1])-1] = num[int(a[1])-1]+1

for i in range(int(b[0])):
    print(num[i])

Submission status: Accepted

Solution code:
a,b=map(int,input().split())

alllist=[]

for i in range(b):
    tmp=list(map(int,input().split()))
    alllist.extend(tmp)

for chk in range(a):
    print(alllist.count(chk+1))

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = map(int, raw_input().split())
d = defaultdict(int)
for _ in range(m):
    a,b = map(int, raw_input().split())
    d[a] += 1
    d[b] += 1
for p in range(1,n+1):
    print d[p]

Submission status: Accepted

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

cities = [[] for i in range(N)]

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

for city in cities:
    print(len(city))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for i in range(n):
    ans = 0
    for j in range(n):
        ans += graph[j + 1][i + 1]
    print(ans)