Problem:


Score: 300 points

Problem Statement

In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.

City i is established in year Y_i and belongs to Prefecture P_i.

You can assume that there are no multiple cities that are established in the same year.

It is decided to allocate a 12-digit ID number to each city.

If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x.

Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits.

Find the ID numbers for all the cities.

Note that there can be a prefecture with no cities.

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq P_i \leq N

1 \leq Y_i \leq 10^9

Y_i are all different.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
P_1 Y_1
:
P_M Y_M

Output

Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...).

Sample Input 1

2 3
1 32
2 63
1 12

Sample Output 1

000001000002
000002000001
000001000001

As City 1 is the second established city among the cities that belong to Prefecture 1, its ID number is 000001000002.

As City 2 is the first established city among the cities that belong to Prefecture 2, its ID number is 000002000001.

As City 3 is the first established city among the cities that belong to Prefecture 1, its ID number is 000001000001.

Sample Input 2

2 3
2 55
2 77
2 99

Sample Output 2

000002000001
000002000002
000002000003



Sample input:
2 3
1 32
2 63
1 12


Sample output:
000001000002
000002000001
000001000001

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n,m=map(int,input().split())
l=[]
id_list=[]
for i in range(m):
  obj = list(map(int, input().split()))
  obj.append(i+1)
  l.append(obj)
l=sorted(l, key=itemgetter(1))
idx=0
for j in range(m):
  id_obj=[]
  if j == 0:
    idx=1
  else:
    if l[j][0] == l[j-1][0]:
      idx+=1
    else:
      idx =1
  id_obj.append(l[j][2])
  id_obj.append(str(l[j][0]).zfill(6)+str(idx).zfill(6))
  id_list.append(id_obj)
id_list = sorted(id_list)
for k in range(m):
  print(id_list[k][1])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n,m=map(int,input().split())
l=[]
id_list=[]
for i in range(m):
  l.append(list(map(int, input().split())))
l=sorted(l, key=itemgetter(1))
idx=0
for j in range(m):
  if j == 0:
    idx=1
  else:
    if l[j][0] == l[j-1][0]:
      idx+=1
    else:
      idx =1
  id_list.append(str(l[j][0]).zfill(6)+str(idx).zfill(6))
print(sorted(id_list))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
kv = {}
lst = []
for _ in range(M):
    x, y = map(int, input().split())
    lst.append("{0} {1}".format(x, y))
    if x in kv:
        kv[x][y] = 1
    else:
        kv[x] = {y:1}

for k1 in sorted(kv.keys()):
    keys = sorted(kv[k1].keys())
    for idx, k2 in enumerate(keys, 1):
        kv[k1][k2] = idx

print(kv)
for s in lst:
    x, y = map(int, s.split())
    print("{0:06d}{1:06d}".format(x,kv[x][y]))

Submission status: Wrong Answer

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

N, M = [int(x) for x in input().split()]
P_Y_li = []
for _ in range(M):
    P_Y_li.append([_] + [int(x) for x in input().split()])

prev_P = 0
num_x_li = {}
for i in sorted(P_Y_li, key=lambda x:(x[2],x[1])):
    if prev_P != i[1]:
        # init
        prev_P = i[1]
        counter = 1
    num_x_li[i[0]] = counter
    counter += 1

for i in P_Y_li:
    print(str(i[1]).rjust(6,'0') + str(num_x_li[i[0]]).rjust(6,'0'))

Submission status: Wrong Answer

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

N, M = [int(x) for x in input().split()]
P_Y_li = []
for _ in range(M):
    P_Y_li.append([_] + [int(x) for x in input().split()])

prev_P = 0
num_x_li = {}
for i in sorted(sorted(P_Y_li, key=lambda x:x[1]), key=lambda x:x[2]):
    if prev_P != i[1]:
        # init
        prev_P = i[1]
        counter = 1
    num_x_li[i[0]] = counter
    counter += 1

for i in P_Y_li:
    print(str(i[1]).rjust(6,'0') + str(num_x_li[i[0]]).rjust(6,'0'))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cities = ["{}{:010}".format(*tuple(map(int, input().split()))) for _ in range(M)]
sorted_cities = sorted(cities)

ids = {}
cnt = 1
before = -1
for c in sorted_cities:
    id_ = c[:-10]
    if before != id_:
        before = id_
        cnt = 1
    else:
        cnt += 1
    ids[c] = cnt

[print("{:06}{:06}".format(int(c[:-10]), ids[c])) for c in cities]

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cities = [float("{}.{}".format(*tuple(map(int, input().split())))) for _ in range(M)]
sorted_cities = sorted(cities)

ids = {}
cnt = 1
before = -1
for c in sorted_cities:
    id_ = int(c)
    if before != id_:
        before = id_
        cnt = 1
    else:
        cnt += 1
    ids[c] = cnt

[print("{:06}{:06}".format(int(c), ids[c])) for c in cities]

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cities = [int("{}{:06}".format(*tuple(map(int, input().split())))) for _ in range(M)]
sorted_cities = sorted(cities)

ids = {}
cnt = 1
before = -1
for c in sorted_cities:
    id_ = c//1000000
    if before != id_:
        before = id_
        cnt = 1
    else:
        cnt += 1
    ids[c] = cnt

[print("{:06}{:06}".format(c//1000000, ids[c])) for c in cities]

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cities = [int("{}{:06}".format(*tuple(map(int, input().split())))) for _ in range(M)]
sorted_cities = sorted(cities)

ids = {}
cnt = 0
before = sorted_cities[0]//1000000
for c in sorted_cities:
    id = c//1000000
    if before != id:
        before = id
        cnt = 1
    else:
        cnt += 1
    ids[c] = cnt

[print("{:06}{:06}".format(c//1000000, ids[c])) for c in cities]

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits



def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))

def update(bit,i, dp):
    bit[i] = dp
    return bit

def query(bit, i):
    lis = [bit[j] for j in range(i)]
    return max(lis)


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n,m=MAP()

py = [LIST() for _ in range(m)]
py = [[i,x[0],x[1]] for i,x in enumerate(py)]
lis=deepcopy(py)
lis.sort(key=lambda x: (x[1], x[2]))

ans = [""] * m

tmp=1
ct = 1
i = 0

for x in lis:
    if tmp!=x[1]:
        tmp = lis[i][1]
        ct = 1
    ans[x[0]] = '{:06}{:06}'.format(x[1], ct)
    ct += 1
        
for x in ans:
    print(x)

Submission status: Wrong Answer

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

def main():
    ps = [[] for _ in range(N)]
    print(ps)

    for m in range(M):
        p, y = [int(n) for n in input().split()]
        pref = ps[p - 1]
        pref.append([m, y])

    result = []

    for i, pref in enumerate(ps):
        pref.sort(key=lambda p: p[1])
        for j, p in enumerate(pref):
            result.append([p[0], '{:06}{:06}'.format(i + 1, j + 1)])

    result.sort(key=lambda x: x[0])

    for p in result:
        print(p[1])

    # ans = '\n'.join(map(lambda p: p[1], result))
    # print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    ps = [[] for _ in range(N)]
    print(ps)

    for m in range(M):
        p, y = [int(n) for n in input().split()]
        pref = ps[p - 1]
        pref.append([m, y])

    result = []

    for i, pref in enumerate(ps):
        pref.sort(key=lambda p: p[1])
        for j, p in enumerate(pref):
            result.append([p[0], '{:06}{:06}'.format(i + 1, j + 1)])

    result.sort(key=lambda x: x[0])

    ans = '\n'.join(map(lambda p: p[1], result))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
P = [list(map(int,input().split()))+[0] for i in range(m)]
X = sorted(P,key = lambda x:x[1])
city = {}
for p,y,z in X:
    if p in city:
        city[p] += 1
    else:
        city[p] = 1
    z = city[p]
for p,y,z in P:
    print(str(p).zfill(6)+str(z).zfill(6))

Submission status: Wrong Answer

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

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

#print (lst)
lst.sort()
#print (lst)

ken = -1
x = 0
for j in range(M):
    if ken != lst[j][0]: #1つ前と市の名前が違う
        x = 1 #
        ken = lst[j][0]
        P = '{:0>6}'.format(ken)
    else: #1つ前と市の名前が同じ
        x += 1
    X = '{:0>6}'.format(x)
    ans = P + X
    print (ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
PY = []
for i in range(M):
    p, y = map(int,input().split())
    PY.append((p,y,i))
PY.sort(key= lambda x:(x[0],x[1]))
ID = [None]*M
cnt = 0
current = PY[0][0]
for i in range(M):
    p,y,j = PY[i]
    cnt += 1
    if current != p:
        cnt = 1
    ID[j] = "{:06}{:06}".format(p,cnt)
for i in range(M):
    print(ID[i])

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
PY = []
for i in range(M):
    p, y = map(int,input().split())
    PY.append((p,y,i))
PY.sort()
ID = [None]*M
cnt = 0
current = PY[0][0]
for i in range(M):
    p,y,j = PY[i]
    cnt += 1
    if current != p:
        cnt = 1
    ID[j] = "{:06}{:06}".format(p,cnt)
for i in range(M):
    print(ID[i])

Submission status: Wrong Answer

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

print(id)

pre_num=[0]*(n+1)
ans=[""]*m

id.sort(key=lambda x:x[1])

for p,y,i in id:
    pre_num[p]+=1
    ans[i]=str(p).zfill(6)+str(pre_num[p]).zfill(6)
    
print("\n".join(ans))

Submission status: Wrong Answer

Solution code:
#coding: utf-8
from copy import deepcopy


def main():
    N, M = map(int, input().split())
    p_dict = {}
    for i in range(M):
        p, y = map(int, input().split())
        if p not in p_dict.keys():
            p_dict[p] = [[y, p, i]]
        else:
            #yとp元の順番を入れとく
            p_dict[p].append([y, p, i])
    ans = []
    for p in p_dict.keys():
        print(p)
        p_dict[p].sort()
        for i in range(len(p_dict[p])):
            #昇順で並べたときの順番を入れとく
            p_dict[p][i].append(i+1)
            ans.append(p_dict[p][i])
    #print(p_dict[p_list[0][0]])
    print(p_dict)
    #ans = [y, p, input_index, sorted_index]
    ans.sort(key=lambda x: x[2])
    print(ans)
    for y, p, oi, si in ans:
        print("{:06d}{:06d}".format(p, si))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
from copy import deepcopy
def main():
	N, M = map(int, input().split())
	p_list = []
	p_dict = {}
	for i in range(M):
		p, y = map(int, input().split())
		p_list.append([p, y])
		if p not in p_dict.keys():
			p_dict[p] = [y]
		else:
			p_dict[p].append(y)
	for p in p_dict.keys():
		p_dict[p].sort()
	for i in range(M):
		str1 = str(p_list[i][0])
		str2 = p_dict[p_list[i][0]].index(p_list[i][1])
		print("0" * (6 - len(str(str1))) + str(str1) + "0" * (6 - len(str(str2))) + str(str2 + 1))
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
from copy import deepcopy
N, M = map(int, input().split())
p_list = []
p_dict = {}
for i in range(M):
	p, y = map(int, input().split())
	p_list.append([p, y])
	if p not in p_dict.keys():
		p_dict[p] = [y]
	else:
	    p_dict[p].append(y)
for p in p_dict.keys():
    p_dict[p].sort()
for i in range(M):
    str1 = str(p_list[i][0])
    str2 = p_dict[p_list[i][0]].index(p_list[i][1])
    print("0" * (6 - len(str(str1))) + str(str1) + "0" * (6 - len(str(str2))) + str(str2 + 1))

Submission status: Wrong Answer

Solution code:
from scipy.stats import rankdata

N, M = map(int, input().split())
p_size = [0] * N
p_years = [list() for _ in range(N)]
p_ranks = [None] * N
P = [None] * M
Y = [None] * M
indxs = [0] * M

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    indxs[i] = p_size[P[i] - 1]
    p_size[P[i] - 1] += 1
    p_years[P[i] - 1].append(Y[i])

# Calc rank
for i, years in enumerate(p_years):
    p_ranks[i] = rankdata(years, method='ordinal')


for i in range(M):
    ans1 = str(P[i]).zfill(6)
    rank_tmp = p_ranks[P[i] - 1]
    ans2 = str(rank_tmp[indxs[i]]).zfill(6)
    print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
City = []
for i in range(M):
	c = list(map(int, input().split()))
	c.append(0)
	City.append(c)
print(City)
for i in range(N):
	l = []
	for j in City:
		if j[0] == i + 1:
			l.append(j[1])
	l.sort()
	for j in City:
		if j[0] == i + 1:
			j[2] = l.index(j[1]) + 1
for i in City:
	ID = ("0" * 6 + str(i[0]))[-6:] + ("0" * 6 + str(i[2]))
	print(ID)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
N, M = map(int, input().split())
X = [input().split() for m in range(M)]

X_sort = sorted(X, key=lambda x:(x[0], x[1]))
dic = {}
c = 1
previous_p = X[0][0]
for x in X_sort:
    if previous_p == x[0]:
        dic[str(x)] = str(x[0]).zfill(6) + str(c).zfill(6)
        c += 1
    else:
        dic[str(x)] = str(x[0]).zfill(6) + str(1).zfill(6)
        c = 1
    previous_p = x[0]

for x in X:
    print(dic[str(x)])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  cs.append([y, p])
css = sorted(cs)
for c in css:
  if c[1] in ps:
    ps[c[1]].append(c[0])
  else:
    ps[c[1]] = [c[0]]
[print(str(c[1] * 1000000 + ps[c[1]].index(c[0]) + 1000000000001).lstrip('1')) for c in cs]

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  if p not in ps:
    ps[p] = []   
  ps[p].append(y)
  cs.append([p, y])
  
[ps[p].sort() for p in ps.keys()]
[print(str(c[0] * 1000000 + ps[c[0]].index(c[1]) + 1000000000001).lstrip('1')) for c in cs]

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  if p in ps.keys():
    ps[p].append(y)
  else:
    ps[p] = [y]
  cs.append([p, y])
for p in ps.keys():
  ps[p].sort()

for c in cs:
  print(str(c[0] * 1000000 + ps[c[0]].index(c[1]) + 1000000000001).lstrip('1'))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  if p in ps:
    ps[p].append(y)
  else:
    ps[p] = [y]
  cs.append([p, y])
for p in ps.keys():
  ps[p].sort()

def code(a, b):
  return str(a * 1000000 + b + 1000000000000).lstrip('1')
for c in cs:
  print(code(c[0], ps[c[0]].index(c[1]) + 1))

Submission status: Wrong Answer

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

# input順,県P,Y年,P内通し番号
city_list=[]
for i in range(m):
    p,y=map(int,input().split())
    city_list.append([i,p,y])

city_list=sorted(city_list,key=lambda x:(x[1],x[2]))

city=city_list[0][1]
count=0
for i in range(m):
    if city == city_list[i][1]:
        count+=1
    else:
        count=1
    city_list[i].append(count)

city_list=sorted(city_list,key=lambda x:(x[0]))

for id in city_list:
    print(str(id[1]).zfill(6) + str(id[3]).zfill(6))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = input().split()
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)

ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(p[i].zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(p[i].zfill(6) + str(count).zfill(6))
        count += 1
ans1 = zip(index,ans)
ans1 = sorted(ans1)
index,ans = zip(*ans1)
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = input().split()
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)

ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(p[i].zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(p[i].zfill(6) + str(count).zfill(6))
ans1 = zip(index,ans)
ans1 = sorted(ans1)
index,ans = zip(*ans1)
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = input().split()
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)

ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(p[i].zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start == p[i]
        ans.append(p[i].zfill(6) + str(count).zfill(6))
ans1 = zip(index,ans)
ans1 = sorted(ans1)
index,ans = zip(*ans1)
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = [dict() for i in range(N)]
ilist = [list(map(int, input().split())) for i in range(M)]
for i, y in ilist:
    l[i - 1][y] = 1
l = [dict(sorted(l[i].items())) for i in range(N)]
for i in range(N):
    for j, k in enumerate(l[i].keys()):
        l[i][k] = "{:06}{:06}".format(i + 1, j + 1)
for n, y in ilist[::-1]:
    print(l[n - 1][y])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = [dict() for i in range(N)]
ilist = [list(map(int, input().split())) for i in range(M)]
for i, y in ilist:
    l[i - 1][y] = 1
l = [dict(sorted(l[i].items())) for i in range(N)]
for i in range(N):
    for j, k in enumerate(l[i].keys()):
        l[i][k] = "{:06}{:06}".format(i + 1, j + 1)
for n, y in ilist:
    print(int(l[n - 1][y]))

Submission status: Wrong Answer

Solution code:
import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
p.sort()
for x,y in p:
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n, m= map(int, (input().split()))
pyi = [list(map(int, (input().split()))) + [i] for i in range(m)]
pyi.sort(key=itemgetter(1))
pyi.sort(key=itemgetter(0))
cityflag = 0
ans = []
for rep in range(m):
    if pyi[rep][0] != pyi[rep - 1][0]:
        cityflag = 0

    cityflag += 1
    ans += [[pyi[rep][0] , cityflag]]

for i in sorted(ans):
    print(str(i[0]).zfill(6) + str(i[1]).zfill(6))

Submission status: Wrong Answer

Solution code:
A = []
D = []

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

for i in range(M):
    PY = list(map(int, input().split()))
    PY.append(i+1)
    A.append(PY)
B = sorted(A)

cnt1 = 0
cnt2 = 0

for i in range(cnt1,M):
    if cnt1 == B[i][0]:
        B[i][0],B[i][1] = B[i][1],B[i][0]
    else:
        pref = str(cnt1)
        len_p = len(pref)
        C = B[cnt2:i]
        cnt1 = B[i][0]
        cnt2 = i
        C = sorted(C)
        len_C = len(C)
        for j in range(len_C):
            x = str(j+1)
            len_x = len(x)
            number = C[j][2]
            ID = "0"*(6-len_p)+pref+"0"*(6-len_x)+x
            y = [number,ID]
            D.append(y)
D = sorted(D)
for j in range(len(D)):
    print(D[j][1])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = [dict() for i in range(N)]
ilist = [list(map(int, input().split())) for i in range(M)]
for i, y in ilist:
    l[i - 1][y] = 1
l = [dict(sorted(l[i].items())) for i in range(N)]
for i in range(N):
    for j, k in enumerate(l[i].keys()):
        l[i][k] = "{:06}{:06}".format(i + 1, j + 1)
for n, y in ilist:
    print(l[n - 1][y])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
py = {}
for i in range(m):
    p,y = map(int,input().split())
    py[i] = (p,y)
ans = sorted(py.items(),key=lambda x:x[1])
#print(ans[0][1][1])
count = 1
number = []
number.append(count)
#print(ans)
for i in range(1,m):
    if ans[i][1][0] == ans[i-1][1][0]:
        count += 1
    else:
        count = 1
    number.append(count)
#print(number)

for i in range(m):
    a = "{0:06d}".format(ans[i][1][0])
    b = "{0:06d}".format(number[i])
    print(a,end="")
    print(b)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
import collections
import math
import sys
import itertools
N,M = map(int,input().split())
nums = []
for i in range(M):
    P,Y = map(int,input().split())
    nums.append([P,Y,i])
nums.sort(key=itemgetter(1))
count = 0
count2 = 1
anss= []
for i in nums:
    if i[0]==count:
        count2+=1
        ans = str(i[0]).zfill(6)+str(count2).zfill(6)
        anss.append([ans,i[2]])
    else:
        count = i[0]
        count2 = 1
        ans = str(i[0]).zfill(6)+str(count2).zfill(6)
        anss.append([ans,i[2]])
anss.sort(key=itemgetter(1))
for ans in anss:
    print(ans[0])

Submission status: Wrong Answer

Solution code:
import sys

def i2nn():
    return sp2nn(sys.stdin.readline())

def ii2ss(n):
    return [sys.stdin.readline() for _ in range(n)]

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

def main(N, ss):
    nn = [[] for _ in range(N+1)]
    for s in ss:
        p, y = sp2nn(s)
        nn[p].append(y)
    for n2 in nn:
        n2.sort()
    for i, n2 in enumerate(nn):
        for j, n in enumerate(n2):
            print('%06d%06d' % (i, j+1))

N, M = i2nn()
main(N, ii2ss(M))

Submission status: Wrong Answer

Solution code:
import sys

def i2nn():
    return sp2nn(sys.stdin.readline())

def ii2ss(n):
    return [sys.stdin.readline() for _ in range(n)]

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

def main(N, ss):
    nn = [[] for _ in range(N+1)]
    for s in ss:
        p, y = sp2nn(s)
        nn[p].append(y)
    for n2 in nn:
        n2.sort()
    for i, n2 in enumerate(nn):
        for n in n2:
            print('%06d%06d' % (i, n))

N, M = i2nn()
main(N, ii2ss(M))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    map_[p].append(i)
for val in map_.values():
    val.sort()

ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
prefecture, city = map(int, input().split(' '))
dic_cities = {}
born_ls = []
for i in range(1, prefecture + 1):
    dic_cities[i] = list()
for i in range(0, city):
    pre, born = map(int, input().split(' '))
    born_ls.append([pre, born])
    dic_cities[pre].append(born)
    
for i in dic_cities.keys():
    dic_cities[i] = sorted(dic_cities[i])

for input_info in born_ls:
    for i in range(0, len(dic_cities[input_info[0]])):
        if dic_cities[input_info[0]][i] == input_info[1]:
            print("{:08}{:08}".format(input_info[0], i + 1))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{0:06}{0:06}'.format(p, d[(p, y)]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{0:6}{0:6}'.format(p, d[(p, y)]))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lis  = [list(input().split()) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis,key =lambda x:(x[0],x[1]))
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lis  = [list(input().split()) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis)
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lis  = [list(input().split()) for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis)
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
        print('if')
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lis  = [list(input().split())+[_] for _ in range(M)]
ans_lis = [0] * M
lis_sort = sorted(lis)
flag = lis_sort[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lis  = [list(input().split())+[_] for _ in range(M)]
lis_sort = sorted(lis)
flag = lis[0][0]
i = 1
for x in lis_sort:
    if x[0] != flag:
        flag = x[0]
        i=1
    x[1] = '0'*(6-len(str(i)))+str(i)
    i+=1
for x in lis:
    print('0'*(6-len(x[0])),x[0],x[1],sep='')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
flag = 0
lis  = [list(map(int,input().split())) for _ in range(M)]
ans_pra_lis = []
ans_beh_lis = [0] * M
lis_sort = sorted(lis)
for _ in lis:
    s = str(0)*(6-len(str(_[0]))) + str(_[0])
    ans_pra_lis.append(s)
i = 1
for _ in range(len(lis_sort)):
    if flag != lis_sort[_][0]:
        flag = lis_sort[_][0]
        i = 1
    ans_beh_lis[lis.index(lis_sort[_])] = str(0)*(6-len(str(i))) + str(i)
    i += 1
for x,y in zip(ans_pra_lis,ans_beh_lis):
    print(x,y)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
py_list = []
d = dict()
for i in range(M):
    p,y = map(int,input().split())
    py_list.append([p,y])
py_sorted =  sorted(py_list)
p_temp = py_sorted[0][0]
count = 1
for p,y in py_sorted:
    if p_temp != p:
        p_temp = p
        count = 1
    d[(p,y)] = count
    count += 1

for i in range(M):
    s = d[(py_list[i][0],py_list[i][-1])]
    s = str(s)
    print(str(py_list[i][0]).zfill(6),s.zfill(6))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = []
for i in range(m):
	a.append([int(n) for n in input().split()])
	a[i].append(i)
print(a)
b = []
counter = 0
counter1 = 1
for i in range(m):
	c = ""
	if a[i][0] < 100000:
		getlen = len(str(a[i][0]))
		c = "0" * (6 - getlen) + str(a[i][0])
	else:
		c = str(a[i][0])
	if i == 0:
		c += "000001"
		counter = a[0][0]
	elif a[i][0] == counter:
		getlen = len(str(counter1 + 1))
		c += "0" * (6 - getlen) + str(counter1 + 1)
		counter1 += 1
	else:
		counter1 = 1
		c += "000001"
		counter = a[i][0]
	a[i].append(c)

for i in range(m):
	a[i][2], a[i][0] = a[i][0], a[i][2]
a = sorted(a)
for i in range(m):
	print(a[i][3])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
data = [[] for _ in range(N+1)]
raw_data = [[0]*2 for _ in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    data[p].append(y)
    raw_data[i] = [p, y]

for i in range(N):
    data[i].sort()

for i in range(M):
    p, y = raw_data[i][0], raw_data[i][1]

    num = data[p].index(y) + 1

    s = str(p).zfill(6) + str(num).zfill(6)
    print(s)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]
sPY = sorted(PY, key=lambda py: py[1])

i = 1
bp = 1
d = {}
for p, y in sPY:
    if p != bp:
        i = 1
        bp = p
    d[y] = i
    i += 1

for p, y in PY:
    print("{0:06}{1:06}".format(p, d[y]))

Submission status: Wrong Answer

Solution code:
def generate_id(p, x):
    return str(p).zfill(6) + str(x).zfill(6)

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

A = []
B = {}
C = {}

for i in range(M):
    a = tuple(input().split())
    A.append(a)

    if a[0] in B:
        t = B[a[0]]
        t.append(a[1])
        B[a[0]] = t
    else:
        B[a[0]] = [a[1]]

for k, vs in B.items():
    vs = sorted(vs)
    for i, v in enumerate(vs):
        C[(k, v)] = i + 1

for a in A:
    print(generate_id(a[0], C[a]))

Submission status: Wrong Answer

Solution code:
import sys
from operator import itemgetter as ig
input=sys.stdin.readline

m,n=map(int,input().split())
dt=[]
for i in range(n):
    p,y = map(int, input().split())
    dt+=[[i,p,y,0]]
dt.sort(key=ig(2,1))
pi=1
prep=0
for x in dt:
    if prep==x[1]:
        pi+=1
    else:
        pi=1
    x[3]=pi
    prep=x[1]
dt.sort()
for x in dt:
    print(str(x[1]).zfill(6)+str(x[3]).zfill(6))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

N,M = map(int,input().split())
question_dic = defaultdict(list)
question_dics = defaultdict(list)
for _ in range(M):
    city,value = map(int,input().split())
    question_dic[city].append(value)
for key,value in question_dic.items():
    question_dics[key] = sorted(value)
for key,value in question_dic.items():
    for v in value:
        print("%06d%06d"%(key,question_dics[key].index(v)+1))

Submission status: Wrong Answer

Solution code:
import numpy as np
from bisect import bisect_right
from time import time
start = time()
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
# n, m = 10**5, 10**5
# p = [10**5]*m
# y = [i + 1 for i in range(m)]
for i in range(m):
    p_, y_ = map(int, input().split())
    # p_, y_ = p[i], y[i]
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))

print(time() - start)