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:
import numpy as np
from time import time
n, m = map(int, input().split())
p = []
y = []
# n = 10**5
# m = 10**5
# # p = [i + 1 for i in range(m)]
# p = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] * 10**4
# y = [i + 1 for i in range(m)]
d = {}
start = time()
for n_ in range(n):
    d[n_ + 1] = []
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])
    d[i] = np.argsort(d[i]) + 1
count = [0]*n
for i in range(m):
    p_ = p[i]
    out = p_ * 10**6 + d[p_][count[p_ - 1]]
    count[p_ - 1] += 1
    print('{:012d}'.format(out))
# id_list = []
# for key in d:
#     for n_ in d[key]:
#         id_list.append(key*10**6 + n_)
#         # id_list.append('{:06d}{:06d}'.format(key, n_))
# id_list = sorted(id_list)
# for id_ in id_list:
#     print('{:012d}'.format(id_))
# print(time() - start)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())
p = []
y = []
d = {}
for n_ in range(n):
    d[n_ + 1] = []
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = np.argsort(d[i]) + 1
id_list = []
for key in d:
    for n_ in d[key]:
        id_list.append('{:06d}{:06d}'.format(key, n_))
id_list = sorted(id_list)
for id_ in id_list:
    print(id_)

Submission status: Wrong Answer

Solution code:
import numpy as np

n, m = map(int, input().split())
p = []
y = []
d = {}
for i in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
    if p_ not in d.keys():
        d[p_] = [y_]
    else:
        d[p_].append(y_)
for i in d.keys():
    d[i] = np.argsort(d[i])
for i in range(m):
    p_ = p[i]
    y_ = d[p_][0]
    d[p_] = np.delete(d[p_], 0)
    print('{:06d}{:06d}'.format(p_, y_ + 1))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
#py=[[[]]*m]
py=[[]]*m
y=[[]]*n
#for i in range(m):
#    py.append([])
#for i in range (n):
#    y.append([])
for i in range(m):
    py[i]=list(map(int,input().split()))
    y[py[i][0]-1].append(py[i][1])
for i in range(n):
    y[i].sort()
#print(py)
#print(y)
for i in range(m):
    if py[i][0]<10:
        print("00000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))
    elif  py[i][0]<100:
        print("0000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))
    elif py[i][0]<1000:
        print("000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))
    elif py[i][0]<10000:
        print("00"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))
    elif py[i][0]<100000:
        print("0"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))
    else:
        print(str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

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

npy = []

for i in range(m):

    pyy=list(map(int,input().split()))
    pyy.append(i)
    py.append(pyy)

print(py)
py.sort(key=itemgetter(0,1))

print(py)

num = 1

npy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])


for i in range(m-1):
    if py[i+1][0] == py[i][0]:
        num = num + 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])
    else:
        num = 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])

npy.sort(key=itemgetter(1))

for j in range(m):
    print(npy[j][0])

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for _ in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])

city = {}
for i in range(M):
  p, y = sort_PY[i][0], sort_PY[i][1]
  if p in city:
    city[p] += 1
  else:
    city[p] = 1
  sort_PY[i][2] = city[p]
  print(city)
for p, y, z in PY:
  print(str(p).zfill(6)+str(z).zfill(6))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
# i は 通し番号
cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))
print(cities)
pref = cities[0]
counter = 1
for city in cities:
    if pref != city[0]:
        counter = 1
    pref = city[0]
    rank = counter
    number = str(pref).zfill(6) + str(rank).zfill(6)
    city.append(number)
    counter += 1
for i in sorted(cities, key=lambda x: x[2]):
    print(i[3])

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])
ans = ['0'] * m
py.sort()
print(py)
j = 0
for i in range(m):
    if j!= py[i][0]:
        j = py[i][0]
        c=1
    ans[py[i][2]] = str(py[i][0]).zfill(6) + str(c).zfill(6)
    c += 1
for i in range(m):
    print(ans[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([i,p,y])
#py = [list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    if prev_p != sorted_py[i][1]:
        num = 1
    p = str(sorted_py[i][1])
    prev_p = p
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

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([i,p,y])
#py = [list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    if prev_p != sorted_py[i][1]:
        num = 1
    p = str(sorted_py[i][1])
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    prev_p = p
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

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([i,p,y])
#py = [list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = sorted_py[0][1]
for i in range(m):
    if prev_p != sorted_py[i][1]:
        num = 1
    p = str(sorted_py[i][1])
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

Submission status: Wrong Answer

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

for i in range(M):
    j,k = map(int,input().split())
    list[j-1].append((k,i))

ans = [None]*M

for i,j in enumerate(list):
    j.sort()
    for k,(l,m) in enumerate(j):
        ans[m] = "%06d%06d" % (i+1,k+1)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int,input().split())
P_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')
r = np.array(range(0, M))
P_Y_list = np.insert(P_Y_list, 0, r, axis=1)
sorted_P_Y = P_Y_list[P_Y_list[:,2].argsort(),:] # yearで並び替え
counts = (np.zeros(N+1)).astype(int)
id_list = []
for i, p, y in sorted_P_Y:
    counts[p] += 1
    id_list.append([i, str(p).zfill(6) + str(counts[p]).zfill(6)])
id_list = np.array(id_list)
id_list = id_list[id_list[:,0].argsort(),:]
for _, id in id_list:
    print(id)

Submission status: Wrong Answer

Solution code:
debug = 0
"""
N: state num
M: city num
"""


if debug:
    N = 2
    m = 10
else:
    (N, M) = list(map(int, input().split()))

if debug:
    p_y_list = [
        [1, 30]
        ,[1, 20]
        ,[1, 10]
        ,[1, 3]
        ,[2, 63]
        ,[2, 33]
        ,[2, 23]
        ,[3, 21]
        ,[3, 7]
    ]

city_id_list = []
for z in range(M):
# for (P, Y) in p_y_list:
    
    if not debug:
        (P, Y) = list(map(int, input().split()))

    city_id_list.append([Y, P])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0])

state_cnt = {}
tmp_list = []
for (Y, P) in city_id_list:
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
    
    tmp_list.append([state_cnt[P], tmp_id])
    
for cid in sorted(tmp_list, key=lambda x: x[0]):
    print(cid[1])

Submission status: Wrong Answer

Solution code:
debug = 0
"""
N: state num
M: city num
"""


if debug:
    N = 2
    m = 10
else:
    (N, M) = list(map(int, input().split()))

if debug:
    p_y_list = [
        [1, 30]
        ,[1, 20]
        ,[1, 10]
        ,[1, 3]
        ,[2, 63]
        ,[2, 33]
        ,[2, 23]
        ,[3, 21]
        ,[3, 7]
    ]

city_id_list = []
for z in range(M):
# for (P, Y) in p_y_list:
    
    if not debug:
        (P, Y) = list(map(int, input().split()))

    city_id_list.append([Y, P])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0])

state_cnt = {}
tmp_list = []
for (Y, P) in city_id_list:
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)
    
    tmp_list.append([state_cnt[P], tmp_id])
    
for cid in sorted(tmp_list, key=lambda x: (x[0], x[1])):
    print(cid[1])

Submission status: Wrong Answer

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

state_cnt = {}
city_id_list = []
city_id_dict = {}
for z in range(M):
# for (P, Y) in p_y_list:
    
    (P, Y) = list(map(int, input().split()))

    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    state_num = str(P).zfill(6)
    city_num = str(state_cnt[P]).zfill(6)
    tmp_id = state_num + city_num

#     city_id_list.append([Y, P, tmp_id])
    
    city_id_dict[Y] = tmp_id
    
# city_id_list = sorted( city_id_list, key= lambda x: x[0] )
city_id_dict = sorted(city_id_dict.items())
for cid in city_id_dict:
    print(cid[1])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print("{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0])))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print(["{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print(["{:0=10}".format(i[0]), "{:0=10}".format(pydict.get(i[0]))])

Submission status: Wrong Answer

Solution code:
"""
N: state num
M: city num
"""


(N, M) = list(map(int, input().split()))
# N = 2
# m = 3

# p_y_list = [
#     [1, 32]
#     ,[2, 63]
#     ,[1, 12]
# ]

state_cnt = {}
city_id_list = []
for z in range(M):
# for (P, Y) in p_y_list:
    
    (P, Y) = list(map(int, input().split()))

    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    state_num = str(P).zfill(6)
    city_num = str(state_cnt[P]).zfill(6)
    tmp_id = state_num + city_num

    city_id_list.append([Y, P, tmp_id])
    
city_id_list = sorted( city_id_list, key= lambda x: x[0] )

state_cnt = {}
tmp_list = []
for num, (Y, P, tmp_id) in enumerate(city_id_list):
    
    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    tmp_list.append([state_cnt[P], tmp_id])
    
    
tmp_list = sorted(tmp_list, key=lambda x: x[0]) 
for (_, city_id) in tmp_list:
    print(city_id)

Submission status: Wrong Answer

Solution code:
"""
N: state num
M: city num
"""

state_cnt = {}
city_id_dict = {}

(N, M) = list(map(int, input().split()))
# N = 2
# m = 3

for z in range(M):
# p_y_list = [
#     [1, np.random.randint(100)]
#     ,[3, np.random.randint(100)]
#     ,[2, np.random.randint(100)]
#     ,[2, np.random.randint(100)]
#     ,[1, np.random.randint(100)]
#     ,[2, np.random.randint(100)]
    
# ]
# for (P, Y) in p_y_list:
    (P, Y) = list(map(int, input().split()))

    if P not in state_cnt.keys():
        state_cnt[P] = 1
    elif P in state_cnt.keys():
        state_cnt[P] += 1
        
    state_num = str(P).zfill(6)
    city_num = str(state_cnt[P]).zfill(6)
    tmp_id = state_num + city_num
    city_id_dict[Y] = tmp_id
    
# get_state = set(map(int, state_cnt.keys()))
# all_state = set(range(1, N+1, 1))
# remain = set(all_state) - set(get_state)
# for num in ramain:
#     tmp_id = str(num).zfill(6) + "0"*6
#     city_id_list.append(tmp_id)
    
for _, city_id in sorted(city_id_dict.items()):
    print(city_id)

Submission status: Wrong Answer

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

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n, m = LI()
    py = LIR(m)
    city = [[] for i in range(n)]
    for p, y in py:
        city[p-1].append(y)
        city[p-1].sort()
    for p, y in py:
        a = "00000" + str(p)
        a = a[-5:]
        b = "00000" + str(city[p-1].index(y) + 1)
        b = b[-5:]
        print(a+b)    
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[[input().split(),i] for i in range(M)]
li=sorted(li, key=lambda x:x[0][1])
counter=[0]*N
li_id=[]

for j in li:
    counter[int(j[0][0])-1]+=1
    y=str(counter[int(j[0][0])-1])
    ID=('0'*(6-len(j[0][0])))+j[0][0]+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print('%s\n'%k[1])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[[input().split(),i] for i in range(M)]
li=sorted(li, key=lambda x:x[0][1])
counter=[0]*N
li_id=[]

for j in li:
    counter[int(j[0][0])-1]+=1
    y=str(counter[int(j[0][0])-1])
    ID=('0'*(6-len(j[0][0])))+j[0][0]+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print(k[1])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[[input().split(),i] for i in range(M)]
li=sorted(li, key=lambda x:(x[0][0],x[0][1]))
visited=[]
counter=0
li_id=[]

for j in li:
    if j[0][0] in visited:
        counter+=1
    else:
        counter=1
        visited.append(j[0][0])
    y=str(counter)
    ID=('0'*(6-len(j[0][0])))+j[0][0]+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print(k[1])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[[input().split(),i] for i in range(M)]
li=sorted(li, key=lambda x:(x[0][0],x[0][1]))
prev=li[0][0][0]
counter=0
li_id=[]

for j in li:
    if prev==j[0][0]:
        counter+=1
    else:
        counter=1
    y=str(counter)
    ID=('0'*(6-len(j[0][0])))+j[0][0]+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print(k[1])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
li=[input().split() for i in range(M)]
li=sorted(li, key=lambda x:(x[0],x[1]))
prev=li[0][0]
counter=0

for j in li:
    if prev==j[0]:
        counter+=1
    else:
        counter=1
    y=str(counter)
    ID=('0'*(6-len(j[0])))+j[0]+('0'*(6-len(y)))+y
    print(ID)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
t = [[] for i in range(n)]
t2 = [[] for i in range(n)]
for i in range(m):
    t[s[i][0]-1].append(s[i][1])

for i in range(n):
    t1 = np.array(t[i])
    t3 = t1.argsort()
    for j in range(len(t1)):
        t2[i].append(t3[j] + 1)


for i in range(m):
    p = t2[s[i][0] - 1][0]
    k1 = len(list(str(s[i][0])))
    k2 = len(list(str(p)))
    q = (str(0) * (6 - k1)) + str(s[i][0])
    r = (str(0) * (6 - k2)) + str(p)
    print(q + r)
    t2[s[i][0] - 1].pop(0)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
p = []
y = []
for i in range(M):
    p1,y1=[int(i) for i in input().split()]
    p.append(p1)
    y.append(y1)
ans = [0 for _ in range(M)]
for idx in range(M):
    ans[idx] = [idx, p[idx], y[idx]]
ans = sorted(ans, key=lambda x: x[1])
ans = sorted(ans, key=lambda x: x[2])
for idx in range(M):
    if idx == 0:
        ans[idx][2] = 1
    else:
        if ans[idx][1] == ans[idx-1][1]:
            ans[idx][2] = ans[idx-1][2] + 1
        else:
            ans[idx][2] = 1
ans = sorted(ans, key=lambda x: x[0])
for idx in range(M):
    print('{:0=6}{:0=6}'.format(ans[idx][1], ans[idx][2]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
dic = defaultdict(list)
P, X = [], []
for _ in range(M):
  p, x = input().split()
  P.append(p)
  X.append(x)
  dic[p].append(x)
for p in dic:
  dic[p] = sorted(dic[p])
for i in range(M):
  print(P[i].zfill(6) + str(dic[P[i]].index(X[i]) + 1).zfill(6))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
for _ in range(M):
  p, x = input().split()
  print(p.zfill(6) + x.zfill(6))

Submission status: Wrong Answer

Solution code:
def main113():
    import numpy as np

    def number(x):
        return "0" * (6-len(str(x))) + str(x)

    N, M = (int(x) for x in input().split())

    PY = [[] for i in range(N)]
    order = []
    Y_order = []

    for i in range(M):
        P, Y = (int(x) for x in input().split())
        PY[P-1].append(Y)
        order.append([P,Y])

    for i in range(N):
        Y_order.append(np.argsort(np.array(PY[i])))

    for i in range(M):
        P, Y = order[i][0], order[i][1]

        for j in range(len(PY[P-1])):
            if PY[P-1][j] == Y:
                print(number(P) + number(Y_order[P-1][j]+1))

main113()

Submission status: Wrong Answer

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

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

p.sort()
cnt = 1
pre = -1

for city in p:
    if city[0] == pre:
        cnt = cnt + 1
    else:
        pre = city[0]

    city.append("{:0>6}{:0>6}".format(city[0], cnt))

p.sort(key = lambda x: x[2])

for city in p:
    print(city[3])

Submission status: Wrong Answer

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

PY = []
for _ in range(M):
  py = list(map(int,input().split()))
  PY.append(py)

PY.sort()
cnt_pref = {}
for py in PY:
  p,y = py[0],py[1]
  if (p in cnt_pref):
    cnt_pref[p] += 1
  else:
    cnt_pref[p] = 1
  out = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)
  print(out)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys,bisect
# ----------------------------------------------------------------
# Use Solve Function

# 3:import bisect
# 8:# ex) この例では、 bisect() を使って、(たとえば)順序のついた数値の区切り点の集合に基づいて、
#     12:    i = bisect.bisect(breakpoints, score)
#     20:bisect.insort(A, 1)
#     21:bisect.insort(A, 3)
#     22:bisect.insort(A, 5)
#     25:print(bisect.bisect(A,1))

def solve(lines):
    N,M= map(int, lines.pop(0).split(' '))
    NLIST = []
    A = []
    B = []
    for i in range(M):
        P,Y = map(int, lines.pop(0).split(' '))
        if P == 1:
            bisect.insort(A, Y)
        else:
            bisect.insort(B, Y)
        NLIST.append((P,Y))
    for x in NLIST:
        if x[0] == 1:
            n = bisect.bisect(A, x[1])
            print("{:0>6}{:0>6}".format(x[0], n))
        else:
            n = bisect.bisect(B, x[1])
            print("{:0>6}{:0>6}".format(x[0], n))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[]
for i in range(M):
    n,m=input().split()
    a.append([n,m,str(i)])
ans=['0']*M
a.sort()
c=1
j=0
for i in range(M):
    if j!=a[i][0]:
        j=a[i][0]
        c=1
    ans[int(a[i][2])]=a[i][0].zfill(6)+str(c).zfill(6)
    c+=1
for i in range(M):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=[]
for i in range(M):
    n,m=input().split()
    a.append([n,m,str(i)])
ans=['0']*M
a.sort()
c=1
for i in range(M):
    if i>0:
        if a[i][0]==a[i-1][0]:
            c+=1
        else: 
            c=1
    ans[int(a[i][2])]=a[i][0].zfill(6)+str(c).zfill(6)
for i in range(M):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
PY=[]
for i in range(M):
    PY.append(list(map(int,input().split()))+[i+1])
    PY.sort(key=lambda x:(x[0],x[1]))
print(PY)
id=[]
l=[]
while len(PY)>0:
    p=PY[0][0]
    print(p)
    i=0
    print(i)
    while PY[i][0]==p:
        i+=1
        id.append('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(i)))+str(i))
        l.append(PY[i-1][2])
        print(i)
        if i+1>len(PY):
            break
    del PY[:i]
    print(PY)
    print(l)
    print(id)
for i in range(1,M+1):
    print(id[l.index(i)])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]
for i in range(M):
    L[i].append(i)
L.sort(key=lambda x:x[1])
L.sort(key=lambda x:x[0])
city_num=1
#12 to 1
#32 to 2
inside_num=1
for i in range(M):
    if L[i][0]!=city_num:
        city_num+=1
        inside_num=1
    L[i][1]=inside_num
    inside_num+=1
#print(L)
L.sort(key=lambda x:x[2])
for l in L:
    print("{:0=6}{:0=6}".format(l[0],l[1]))#0 padding

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]
L.sort(key=lambda x:x[1])
L.sort(key=lambda x:x[0])
city_num=1#
#12 to 1
#32 to 2
inside_num=1
for i in range(M):
    if L[i][0]==city_num:
        L[i][1]=inside_num
        inside_num+=1
    else:
        city_num+=1
        inside_num=1
        L[i][1]=inside_num
        inside_num+=1
#print(L)
for l in L:
    print("{:0=6}{:0=6}".format(l[0],l[1]))#0 padding

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()
cnt = 1
a = 0
for i in range(M):
    if PY[i][0] == a: cnt += 1
    else: cnt = 1
    a = p
    PY[i][1] = cnt
PY.sort(key=lambda x: x[2])
for i in range(M):
    print(str(PY[i][0]).rjust(6,'0') + str(PY[i][1]).rjust(6,'0'))

Submission status: Wrong Answer

Solution code:
import collections as c
d=c.defaultdict(list)
d2=c.defaultdict(list)
a,b,*q=map(int,open(0).read().split())
for s in range(b):
    g,j=q[2*s],q[2*s+1]
    d[g].append(j)
    d[g]=sorted(d[g])
for t in d.keys():
    for k,v in enumerate(d[t]):
        d2[t].append((v,k+1))
print(d2)

Submission status: Wrong Answer

Solution code:
import collections as c
d=c.defaultdict(list)
d2=c.defaultdict(list)
a,b,*q=map(int,open(0).read().split())
for s in range(b):
    g,j=q[2*s],q[2*s+1]
    d[g].append(j)
    d[g]=sorted(d[g])
for t in d.keys():
    for k,v in enumerate(d[t]):
        d2[t].append((v,k+1))
print(d2)
for s in range(b):
    g,j=q[2*s],q[2*s+1]
    for sss in d2[g]:
        if sss[0]==j:
            print('{:06d}'.format(g)+'{:06d}'.format(sss[1]))

Submission status: Wrong Answer

Solution code:
def identify(N: int, M: int, PY: list) -> list:
    _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]
    _PY.sort(key=lambda x: x[2])
    _PY.sort(key=lambda x: x[1])

    now_p = 0
    now_o = 1
    ids = []
    for i, p, _ in _PY:
        if p != now_p:
            now_p = p
            now_o = 1
        ids.append((i, '{p:08}{o:08}'.format(p=p, o=now_o)))
        now_o += 1

    return [i for _, i in sorted(ids, key=lambda x: x[0])]


if __name__ == "__main__":
    N, M = map(int, input().split())
    PY = [tuple(int(s) for s in input().split()) for _ in range(M)]
    for ans in identify(N, M, PY):
        print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
P = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    P[p-1].append(len(P[p-1])+1)
for i in range(len(P)):
    for j in range(len(P[i])):
        print("{:0=6}{:0=6}".format(i+1, P[i][j]))

Submission status: Wrong Answer

Solution code:
#KoyanagiHitoshiさんのコードを参考にさせていただきました（てかそのままです）
import collections,bisect
n,m = map(int, input().split())

P = [list(map(int,input().split())) for i in range(m)]
x =collections.defaultdict(list)

for i,j in sorted(P):
    x[i] += [j]     #1:[12,32], 2:[63]  みたいにコレクションで市の名前をキーに、できた年をそれぞれ小さい順にリストで格納

for i,j in P:
    num = bisect.bisect(x[i],j)
    print("%06d%06d" % (i, j))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int,input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    j, Y = map(int,input().split())
    Ps[j-1].append([i,Y])
rets = [""]*M
for i,P in enumerate(Ps):
    if len(P)==0:
        continue
    
    inds = np.array(P)[:,0]
    years = np.array(P)[:,1]
    sorts = np.argsort(years)
    
    ## 降順/昇順に手こずりすぎ
    for i,(ind,s) in enumerate(zip(inds,sorts)):
        a = np.where(sorts==i)[0][0]
        rets[ind] = "{:06d}{:06d}".format(i+1,a+1)



for ret in rets:
    print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int,input().split())
Ps = [[] for _ in range(N)]
for i in range(M):
    j, Y = map(int,input().split())
    Ps[j-1].append([i,Y])
print(Ps)
rets = [""]*M
for i,P in enumerate(Ps):
    if len(P)==0:
        continue
    inds = np.array(P)[:,0]
    years = np.array(P)[:,1]
    sorts = np.argsort(years)
    for (j,y,s) in zip(inds,years,sorts):
        rets[j] = "{:06d}{:06d}".format(i+1,s+1)
for ret in rets:
    print(ret)

Submission status: Wrong Answer

Solution code:
import collections,bisect
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
x=collections.defaultdict(list)
for city,year in PY:
    x[city]+=[year]
for city,year in PY:
    num=bisect.bisect(x[city],year)
    print("%06d%06d"%(city,num))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N, M = map(int, input().split())
MY = []
count = 0
for i in range (M):
    MY.append([int(i) for i in input().split()])
sorted(MY)
for i in range (M):
    if MY[i - 1][0] != MY[i][0]:
        count = 1
    else:
        count += 1
    print(str(MY[i][0]).zfill(6) + str(count).zfill(6))

Submission status: Wrong Answer

Solution code:
#encoding:utf-8

n,m = map(int, input().split())
P = []
Y = []
city_tb = []
for i in range(m):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)
    city_tb.append([p,y])

city_tb_ = sorted(city_tb,key=lambda x:x[1])
# print(city_tb_)

count_cities = [0 for i in range(n+1)]
city_cla = {}
for i in range(m):
    count_cities[city_tb_[i][0]] += 1
    city_cla[str(city_tb_[i][0])+str(city_tb_[i][1])]='{:06x}'.format(city_tb_[i][0])+'{:06x}'.format(count_cities[city_tb_[i][0]])

for i in range(m):
    print(city_cla[str(P[i])+str(Y[i])])

Submission status: Wrong Answer

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

kens = []
ps = [0] * M
ys = [0] * M
'''
for _ in range(N):
    kens.append([])
'''
kens = [[]] * N
for i in range(M):
    p,y = (int(i) for i in input().split())
    ps[i] = p
    ys[i] = y
    kens[p-1].append(y)

#print(kens)
for i in range(M):
    num = sorted(kens[ps[i]-1]).index(ys[i]) + 1
    print('{0:06d}'.format(ps[i]) + '{0:06d}'.format(num))

Submission status: Wrong Answer

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

kens = []
ps = []
ys = []
for _ in range(N):
    kens.append([])
for i in range(M):
    p,y = (int(i) for i in input().split())
    ps.append(p)
    ys.append(y)
    kens[p-1].append(y)

print(kens)
for i in range(M):
    num = sorted(kens[ps[i]-1]).index(ys[i]) + 1
    print('{0:06d}'.format(ps[i]) + '{0:06d}'.format(num))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
tmp = [list(map(int, input().split())) for i in range(m)]
city = [[] for i in range(n+1)]
answers = [''] * m

for i, (pref, year) in enumerate(tmp):
    city[pref].append([year, i])
print(city)

for i in range(n+1):
    for j, (year, index) in enumerate(sorted(city[i])):
        ans = str(i).zfill(6) + str(j+1).zfill(6)
        answers[index] = ans

print(*answers, sep='\n')