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: Wrong Answer

Solution code:
# abc061_b.py

N, M = map(int,input().split())
ab = []
for i in range(M):
    a,b = map(int,input().split())
    ab.append(a)
    ab.append(b)
import collections
ab.sort()
C = collections.Counter(ab)
for i,v in C.items():
    print(v)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
ab= [list(map(int,input().split())) for _ in range(m)]
ab=list(itertools.chain.from_iterable(ab))
k=len(set(ab))
for i in range(1,k+1):
    print(ab.count(i))

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
ab= [list(input()) for _ in range(m)]
ab=list(itertools.chain.from_iterable(ab))
k=len(set(ab))
for i in range(1,k+1):
    print(ab.count(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(N+1):
    ans = L.count(j)
    print(ans)

Submission status: Wrong Answer

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(N+1):
    ans = L.count(j)
    print(j)

Submission status: Wrong Answer

Solution code:
#ABC061.B
N,M = map(int,input().split())
L = []
for i in range(M):
    a,b = map(int,input().split())
    L.append([a,b])
for m in range(1,N+1):
    ans = L.count(m)
    print(ans)

Submission status: Wrong Answer

Solution code:
#ABC061.B
N,M = map(int,input().split())
L = []
for i in range(M):
    a,b = map(int,input().split())
    L.append([a,b])
for m in range(N+1):
    ans = L.count(m)
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
dic={n:0 for n in range(1,N)}
for n in range(M):
    for x in map(int, input().split()):
        dic[x]=1
[print(v) for v in dic.values()]

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
dic={}
for n in range(M):
    for x in map(int, input().split()):
        if x in dic.keys():
            dic[x]+=1
        else:
            dic[x]=1
[print(v) for v in dic.values()]

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = []

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

c = Counter(l)
c = sorted(dict(c).items(), key=lambda x:x[0])

"""
collections.Counterを使わない場合

alphabets = []

"""
for v in c:
    print(v[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = []

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

c = Counter(l)
c = sorted(dict(c).items(), key=lambda x:x[0])

for v in c:
    print(v[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = []

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

c = Counter(l)

for k, v in c.items():
    print(v)

Submission status: Wrong Answer

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

dic = {}

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

    try:
        dic[a] += 1
    except:
        dic[a] = 1

    try:
        dic[b] += 1
    except:
        dic[b] = 1

dic = sorted(dic.items(),key=lambda x:x[0])

for i in dic:
    print(i[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

roads = {i : 0 for i in range(N)}
for path in paths:
  roads[path[0]-1] +=1
  roads[path[1]-1] +=1

for i in range(N):
  if not roads[i] == 0:
    print(roads[i])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
c = [input() for i in range(m)]
d = c[0]
for i in range(1,m):
    d += c[i]
e = sorted(d.replace(' ', ''))
for i in range(1,n+1):
    print(e.count(str(i)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
root_dic = {}
for i in range(M):
    root = list(map(int, input().split()))
    for i in range(2):
        if root[i] in root_dic:
            root_dic[root[i]] += 1
        else:
            root_dic[root[i]] = 1
for i, v in sorted(root_dic.items()):
    print(v)

Submission status: Wrong Answer

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

a_lis = [0]*M
b_lis = [0]*M

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


new_lis = a_lis + b_lis
set_new_lis = sorted(set(new_lis))
set_new_lis

for i in set_new_lis:
    print(new_lis.count(i))

Submission status: Wrong Answer

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

new_lis = a_lis + b_lis
set_new_lis = sorted(set(new_lis))
set_new_lis

for i in set_new_lis:
    print(new_lis.count(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

lst = []

for i in range(0,M):
	lst.extend(input().split(" "))
    
print(lst)

for i in range(1,N+1):
	print(lst.count("{}".format(i)))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)

for i in l:
    cnt[i[0]]+=1
    cnt[i[1]]+=1

print(*cnt.values(),sep='\n')

Submission status: Wrong Answer

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

    for i in range(M):
        a_, b_ = map(int, input().split())
        if a_!=b_:
            a.append(a_)
            b.append(b_)
    for i in range(len(a)):
        if (a[i] in bucket) == False:
            bucket[a[i]] = []
        bucket[a[i]].append(a[i])
        if (b[i] in bucket) == False:
            bucket[b[i]] = []
        bucket[b[i]].append(b[i])

    b = sorted(bucket.items())    
    for key, value in b:
        print(len(value))
except EOFError:
    pass

Submission status: Wrong Answer

Solution code:
try:
  N, M = map(int, input().split())
  a = []
  b = []
  bucket = {}
  mx = 0
  for i in range(M):
      a_, b_ = map(int, input().split())
      a.append(a_)
      b.append(b_)
  for i in range(len(a)):
      if (a[i] in bucket) == False:
          bucket[a[i]] = []
      bucket[a[i]].append(a[i])
      if (b[i] in bucket) == False:
          bucket[b[i]] = []
      bucket[b[i]].append(b[i])
      if mx < a[i]:
          mx = a[i]
      if mx < b[i]:
          mx = b[i]
  b = sorted(bucket.items())    
  for key, value in b:
      print(len(value))
except EOFError:
  pass

Submission status: Wrong Answer

Solution code:
from collections import Counter
city, road = list(map(int, input().split()))
road_list = [list(map(int, input().split())) for _ in range(road)]
rl2 = []
for i in road_list:
    rl2.extend(i)

rl2cnt = Counter(rl2)
rl2cs = sorted(rl2cnt.items())
for i in rl2cs:
    print(i[1])

Submission status: Wrong Answer

Solution code:
wlist = []
city, road = map(int, input().split())
for i in range(road):
    wlist.append(input())
dst = []
for i in range(1, city+1):
    count = 0
    for k in wlist:
        if str(i) in k:
            count += 1
    dst.append(count)
for d in dst:
    print(d)

Submission status: Wrong Answer

Solution code:
wlist = []
city, road = map(int, input().split())
for i in range(road):
    wlist.append(input())
dst = []
for i in range(city):
    count = 0
    for k in wlist:
        if str(i) in k:
            count += 1
    dst.append(count)
for d in dst:
    print(d)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if str(mp) not in MPs:
        MPs[str(mp)] = '0'
 
for y in MPs.values():
    print(y)

Submission status: Wrong Answer

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


MPs = {}
for a, b in sorted(ABs, key=lambda i: i[1]):
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1

for mp in range(1, N+1):
    if str(mp) not in MPs:
        MPs[str(mp)] = '0'

for x, y in sorted(MPs.items()):
    print(y)

Submission status: Wrong Answer

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


MPs = {}
for a, b in sorted(ABs, key=lambda i: i[1]):
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1

for mp in range(N):
    if mp in MPs:
        MPs[mp] = 0

for x, y in sorted(MPs.items(), key=lambda j: j[0]):
    print(y)

Submission status: Wrong Answer

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


MPs = {}
for a, b in sorted(ABs, key=lambda i: i[1]):
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1


for x, y in sorted(MPs.items(), key=lambda j: j[0]):
    print(y)

Submission status: Wrong Answer

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,j in sorted(dic.items()):
	print (j)

Submission status: Wrong Answer

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)

import collections
c = collections.Counter(l)
for i in c.values():
    print(i)

Submission status: Wrong Answer

Solution code:
import collections

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

for _ in range(m):
    tmp1,tmp2 = map(int, input().split())
    a.append(tmp1)
    a.append(tmp2)

ans = collections.Counter(a)
ans_sorted = sorted(ans.items(), key=lambda x:x[0])
#print(ans_sorted)

for i in ans_sorted:
    print(i[1])

Submission status: Wrong Answer

Solution code:
import collections

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

for _ in range(m):
    tmp1,tmp2 = map(int, input().split())
    a.append(tmp1)
    a.append(tmp2)

ans = list(collections.Counter(a).values())

for i in ans:
    print(i)

Submission status: Wrong Answer

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

nm = a+b

ans = [0 for i in range(N)]
for j in range(0,(len(nm))):
    i = nm[j]
    ans[i-1] += 1


print(ans)

Submission status: Wrong Answer

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

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

for _, value in sorted(city_road_nums.items()):
    print(value)

Submission status: Wrong Answer

Solution code:
#python3
n,m=map(int, input().split())
l=[]
for i in range(m):
  x,y=map(int, input().split())
  l.extend([x,y])
d={key:l.count(key) for key in set(l)}
for i in d.values():
  print(i)

Submission status: Wrong Answer

Solution code:
t,l=map(int,input().split())
li=[set() for i in range(t)]
for i in range(l):
  a,b= map(int,input().split())
  li[a-1].add(b)
  li[b-1].add(a)
for i in li:
  print(len(i))

Submission status: Wrong Answer

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

for _ in range(m):
    a, b = map(str, input().split())
    road += a + b
print(road)
for i in range(n):
    print(int(road.count(str(i+1))))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = dict()
for i in range(M):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += 1
    else:
        ans[a] = 1
    if b in ans:
        ans[b] += 1
    else:
        ans[b] = 1
        
ans = sorted(ans.items(), key=lambda x:x[0])
for k, v in ans:
    print(v)

Submission status: Wrong Answer

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

ans = dict()
for i in range(M):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += 1
    else:
        ans[a] = 1
    if b in ans:
        ans[b] += 1
    else:
        ans[b] = 1
        
for v in ans.values():
    print(v)

Submission status: Wrong Answer

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

for _ in range(N):
    V.append(set())

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

for node in range(N):
    print(len(V[node]))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
d=dict()
for i in range(b):
  s,l=input().split()
  if s in d.keys():
    d[s]+=1
    if l in d.keys():
      d[l]+=1
    else:
      d[l]=1
  else:
    d[s]=1
    if l in d.keys():
      d[l]+=1
    else:
      d[l]=1

print(d.keys)

Submission status: Wrong Answer

Solution code:
import collections

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

l = []
for m in range(M):
    l += map(int, input().split())

c = collections.Counter(l)
for k, v in sorted(c.items()):
    print(v)

Submission status: Wrong Answer

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

lists=list(set(a))
lists.sort()

for i in lists:
    print(a.count(i))

Submission status: Wrong Answer

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

lists=list(set(a))
lists.sort()

for i in lists:
    print(a.count(i))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
dic = {}
for i in range(M):
  a,b = map(int,input().split())
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] +=1
  if b not in dic:
    dic[b] = 1
  else:
    dic[b] +=1
"""
for j in range(N):
  print(dic[j+1])
"""
order = sorted(dic.keys())
for item in order:
  print(dic[item])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
Q=[]
for i in range(M):
    a=list(map(int,input().split()))
    Q.extend(a)
for i in range(1,N+1):
    if Q.count(i)!=0:
        print(Q.count(i))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
Q=[]
for i in range(M):
    a=list(map(int,input().split()))
    Q.extend(a)
for i in range(N+1):
    if Q.count(i+1)!=0:
        print(Q.count(i+1))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
Q=[]
for i in range(M):
    a=list(map(int,input().split()))
    Q.extend(a)
for i in range(M+1):
    if Q.count(i+1)!=0:
        print(Q.count(i+1))

Submission status: Wrong Answer

Solution code:
import collections
n, m = map(int, input().split())
a = []
for i in range(m):
    t = list(map(str, input().split()))
    a.append(t[0])
    a.append(t[1])
    
c = collections.Counter(a)
for i in range(len(c)):
    print(c[str(i+1)])
if m==0:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n, m = map(int, input().split())
a = []
for i in range(m):
    t = list(map(str, input().split()))
    a.append(t[0])
    a.append(t[1])
    
c = collections.Counter(a)
for i in range(len(c)):
    print(c[str(i+1)])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def in_dic(s,dic):
    if((s in dic) == False):
        dic[s] = 1
    else:
        dic[s] += 1
dic = {}
for i in range(M):
    a,b = map(int,input().split())
    in_dic(a,dic)
    in_dic(b,dic)
for key,value in dic.items():
    print(value)

Submission status: Wrong Answer

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())
loute = a + b
for i in range(n) :
    print(loute.count(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

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

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

aa = collections.Counter(ls)
aa = sorted(aa.items())

for a in aa:
    print(a[1])

Submission status: Wrong Answer

Solution code:
import collections

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

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

ls.sort()
aa = collections.Counter(ls)

for k in aa.values():
    print(k)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = "".join([str(input().replace(" ","")) for i in range(M)])
A_list=list(A)
A_list=[int(j) for j in A_list]
for i in range(1,N+1):
    print(A_list.count(i))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a,b=map(int,input().split())
li=[]
li.append(a)
li.append(b)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
res = [[False] * n for i in range(n)]
for i in range(m):
    a,b = inpl()
    res[a-1][b-1] = True
    res[b-1][a-1] = True
for i in range(n):
    print(res[i].count(True))

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
R = {}
for m in range(M):
    road = [int(i) for i in input().split()]
    for r in road:
        if r in R:
            R[r] += 1
        else:
            R[r] = 1

for _, v in sorted(R.items(), key=lambda x:x[0]):
    print(v)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
list = {}
for i in range(m):
  for j in range(2):
    num=ab[i][j]
    if num in list:
      list[num] += 1
    else:
      list[num] = 1
for j in list.values():
  print(j)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())
AB = []
for _ in range(M):
    ab = input().split()
    if ab[0] == ab[1]:
        AB.extend([ab[0]])
    else:
        AB.extend(ab)
dic_ = collections.Counter(AB)
list_ = sorted(dic_.items())
for l in list_:
    print(l[1])

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())
AB = []
for _ in range(M-1):
    AB.extend(input().split())
dic = collections.Counter(AB)
list_ = sorted(dic.items())
for l in list_:
    print(l[1])

Submission status: Wrong Answer

Solution code:
import collections
N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.extend(input().split())
dic = collections.Counter(AB)
list_ = sorted(dic.items())
for l in list_:
    print(l[1])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [input().split() for _ in range(m)]
dic = {}
for a, b in ab:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
    if b in dic:
        dic[b] += 1
    else:
        dic[b] = 1
for k, v in sorted(dic.items()):
    print(v)

Submission status: Wrong Answer

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], l2[i[1] - 1][i[0] - 1] = 1, 1

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

Submission status: Wrong Answer

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
print(road)
for k in range(N):
    print(road[k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(N):
  print((a==i).sum() + (b==i).sum())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
    
from collections import Counter

c = Counter(road)
for i in c:
    print(c[i])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
n, m = map(int, input().split())
arr = [map(int, input().split()) for _ in range(m)]
d = dd(int)
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: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = []
for i in range(M):
  A, B = map(int, input().split())
  ans.append(A)
  ans.append(B)

for i in range(1, len(ans) + 1):
  if ans.count(i) != 0:
    print(ans.count(i))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

c = Counter(sorted(arr))
for i in c:
    print(c[i])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

c = Counter(sorted(arr))
print(c)
for i in c:
    print(c[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
graph = defaultdict(list)
for i in range(m):
  a,b=map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

for key in sorted(graph.keys()):
  print(len(graph[key]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
L = "".join(list(map(str, sorted(sum(list(map(list, map(tuple, [list(map(int, input().split())) for _ in range(M)]))), [])))))
[print(L.count(str(i))) for i in range(1, N+1)]

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
 
ans={}
for i in range(m):
  sta,gol = road[i][0],road[i][1]
  if sta not in ans:
    ans[sta] = set()
  ans[sta].add(gol)
  
  if gol not in ans:
    ans[gol] = set()
  ans[gol].add(sta)
  
for i in range(1,n+1):
  if i in ans:
  	print(len(ans[i]))
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
# ABC061B - Counting Roads
def main():
    N, M = tuple(map(int, input().split()))
    E = tuple(tuple(map(int, input().split())) for _ in range(M))
    G = [[] for _ in range(N + 1)]
    for v, u in E:
        G[v] += [u]
        G[u] += [v]
    print(*G[1:], sep="\n")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n , m = map(int,input().split())
load = []
for a in range(m):
  town = list(map(int,input().split()))
  load.append(town)
result =[]  
for c in load:
  for d in c:
    result.append(d)
for b in range(n):
  print(result.count(b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
road_list=[]
for _ in range(b):
  road_list+=list(input())
for i in range(1,a+1):
  c = road_list.count(str(i))
  print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    r = 0
    r += a.count(i+1)
    r += b.count(i+1)
print(r)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = []
for i in range(m):
    c, d = map(int, input().split())
    ab.append(c)
    ab.append(d)
s = list(set(ab))
s.sort()
for i in s:
    print(ab.count(i))

Submission status: Wrong Answer

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

route_list = [input() for i in range(m)]
check_text = ''.join(route_list)
for i in range(1, n+1):
    print(check_text.count(str(i)))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = []
for i in range(m):
    c, d = map(int, input().split())
    ab.append(c)
    ab.append(d)
s = list(set(ab))
s.sort()
for i in s:
    print(ab.count(i))

Submission status: Wrong Answer

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(n,0)
  else:
    print(n,c[n])

Submission status: Wrong Answer

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,[])).values()
[print(item) for item in c]