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: Runtime Error

Solution code:
n,m=map(int,input().split())
dic={}
for i in range(m):
  x,y=map(int,input().split())
  if x in dic:
    dic[x]+=1
  else:
    dic[x]=1
  if y in dic:
    dic[y]+=1
  else:
    dic[y]=1
for i in range(1,n+1):
  print(dic[i])

Submission status: Runtime Error

Solution code:
a , b = map(int,input().split())
k = []
for i in range(b):
    t,n = map(int,input().split())
    k.append(t)
    k.append(n)
    
import collections

v = collections.Counter(k)
for i in range(a):
    print (v.most_common()[i][1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

for i in range(M):
    print(B[i])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
N,M = map(int,input().split())
a,b = map(list,input() for i in range(M))
for i in range(N):
  print(a.count(i) + b.count(i))

Submission status: Runtime Error

Solution code:
N,  M = [int(i) for i in input().split()]
cities = {}
for i in range(M):
    cities[i+1] = 0
for i in range(M):
    for c in [int(i) for i in input().split()]:
        cities[c] += 1
for key, val in sorted(cities.items()):
    print(val)

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().strip().split()]
A = [[int(i) for i in input().strip().split()] for j in range(M)]
B = {}
for i in range(N):
    for j in range(M):
        if A[j][0] == i+1:
            B[i] = A[j][1]
for i in range(N):
    print(len(B[i]))

Submission status: Runtime Error

Solution code:
S = input()
ans = 0
for i in range(2**(len(S)-1)):  # 総当たり
    tmp = S[0]  # 先頭だけ格納
    for j in range(len(S)-1):   # mask
        if i & (1<<j):  # iと1をjbitシフトしたものを比較
            tmp += "+"
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)

Submission status: Runtime Error

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: Runtime Error

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

for i in range(a[1]):
  c.append("".join(b[i]))
d = "".join(c)

e = list(d)
for i in range(a[0]):
  f = d.count(i)
  print(f)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
S=[list(map(int,input().split())) for i in range(M)]
for i in range(M):
    S[i].sort()
    for j in range(2):
        S[i][j]=str(S[i][j])
    S[i]=''.join(S[i])
S=list(set(S))
R=[0]*N
for i in range(N):
    n=i+1
    for j in range(M):
        for k in range(2):
            if S[j][k]==str(n):
                R[i]+=1
for i in range(N):
    print(R[i])

Submission status: Runtime Error

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

for i in range(M):
	f,t = map(int,input().split())
	ans[f] += 1
	ans[t] += 1
	
for a in ans:
	print(a)

Submission status: Runtime Error

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

for _ in range(n):
    pass

for i in l:
    print(i)

Submission status: Runtime Error

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

    for _ in range(m):
        lists += input().split()
    
    for i in range(i, n + 1):
        print(lists.count(str(i)))


solve()

Submission status: Runtime Error

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

n, m = map(int, input().split())
A = {}
for i in range(m):
    data = list(map(int, input().split()))
    if data[0] not in A:
        A[data[0]] = 1
    else:
        A[data[0]] += 1
    if data[1] not in A:
        A[data[1]] = 1
    else:
        A[data[1]] += 1

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

Submission status: Runtime Error

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

for i in range(N):
    ans = 0
    for j in range(1, M + 1):
        if i in R[j]:
            ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input())
s=open(0).read().split()
for i in range(n):print(s.count(str(i)))

Submission status: Runtime Error

Solution code:
import msvcrt

nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break
			
for p in range(1,NM_list[0]+1):
	print(n_list[p-1])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

template <class T>
int in(){ T x; cin >> x; return (x);}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[55];
    memset(a,0,sizeof(a));
    rep(i,m){
        int ta,tb;
        cin >> ta >> tb;
        a[ta]++;
        a[tb]++;
    }
    REP(i,1,n+1) cout << a[i] << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
ans=[]
for i in range(m):
    ans.append(line[i][0])
    ans.append(line[i][1])
from collections import Counter
data=Counter(ans)
data=sorted(data.items())
for i in range(n):
    print(data[i][1])

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
line=[tuple(map(int,input().split()))for i in range(m)]
from collections import Counter
ans=[]
for i in range(m):
    ans.append(line[i][0])
    ans.append(line[i][1])
data=Counter(ans)
data=sorted(data.items())
for i in range(n):
    print(data[i][1])

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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
    count[b] += 1

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

Submission status: Runtime Error

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] L= 1
    count[b] += 1

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = list(map(int, input().split()))
a=[input() for i in range(x[0])]
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: Runtime Error

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

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

street = []

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

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

Submission status: Runtime Error

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

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

street = []

for i in range(0,M):
    street.append(0)

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

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# get three integers separated with half-width break
a, b = map(int, raw_input().split())
# output
l1 = []
for i in xrange(b):
    l1.append(0)
for i in xrange(b):
    c, d = map(int, raw_input().split())
#    l1[c-1] = l1[c-1] + 1
    l1[c-1] += 1
    l1[d-1] += 1
for i in xrange(a):
    print l1[i]

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
# get three integers separated with half-width break
a, b = map(int, raw_input().split())
# output
l1 = []
for i in range(b):
    l1.append(0)
for i in range(b):
    c, d = map(int, raw_input().split())
#    l1[c-1] = l1[c-1] + 1
    l1[c-1] += 1

    l1[d-1] += 1
for i in range(a):
    print l1[i]

Submission status: Runtime Error

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

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

for i in road:
    print(i)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
# ==================================================== #
# -*- coding: utf-8 -*
n, m = map(int, input().split())

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

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
ls = []
b_num = 0

for i in range(n):
    a,b = [int(i) for i in input().split()]
    if b_num <= k:
        tmp = [a] * b
        ls.extend(tmp)
        ls.sort()
        b_num += b
    else:
        if(a <= ls[-1]):
            tmp = [a] * b
            ls.extend(tmp)
            ls.sort()
        
print(ls[k-1])

Submission status: Runtime Error

Solution code:
n = input()
a = int(n.split()[0])
b = int(n.split()[1])
c = int(n.split()[2])

if a<=c and c<=b:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

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

for e in Es:
    print(len(e))

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().split()]
g = [[int(i) for i in input().split()] for j in range(N)]
f = [item for sublist in g for item in sublist]
for i in range(1,N+1):
    print(i, f.count(i))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for _ in range(N):
    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: Runtime Error

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

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