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:
N,M = map(int,input().split())

prefec = [[] for _ in range(N)]

for i in range(M):
  p,y = map(int,input().split())
  prefec[p-1].append((y,i))

ans = [None]*M

for i,y in enumerate(prefec):
  y.sort()
  for k ,(y,j) in enumerate(y):
    ans[j] = "%06d%06d" %(i+1,k+1)
    
print(ans,end ='\n')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]
ans_dict = {}
ans_lst = []
for i in range(m):
    if py[i][0] in ans_dict.keys():
        ans_dict[py[i][0]] += 1
        ans_lst.append('{:0=6}'.format(py[i][0]) +
                       '{:0=6}'.format(ans_dict[py[i][0]]))
        print(ans_lst[-1])
    else:
        ans_dict[py[i][0]] = 1
        ans_lst.append('{:0=6}'.format(py[i][0]) +
                       '000001')
        print(ans_lst[-1])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
py = [list(map(int, input().split())) for _ in range(m)]
ans_dict = {}
ans_lst = []
for i in range(m):
    if py[i][0] in ans_dict.keys():
        ans_lst.append('{:0=6}'.format(py[i][0]) +
                       '{:0=6}'.format(py[i][0]-1))
        print(ans_lst[-1])
    else:
        ans_lst.append('{:0=6}'.format(py[i][0]) +
                       '000001')
        print(ans_lst[-1])

Submission status: Wrong Answer

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

for i in range(M):
    P, Y = map(int, input().split())
    PList[P].append([i , Y])

#print(PList)

ans = [0] * M

for P, l in enumerate(PList):
    if not l:
        continue
    l.sort()
    for j, (i, Y) in enumerate(l):
        ans[i] = "{:06d}{:06d}".format(P, j+1)

#print(ans)

print("\n".join(ans))

Submission status: Wrong Answer

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

for i in range(M):
    P, Y = map(int, input().split())
    PList[P].append([i , Y])

#print(PList)

ans = [0] * M

for P, l in enumerate(PList):
    if not l:
        continue
    l.sort()
    for j, (i, Y) in enumerate(l):
        ans[i] = "{:06d}{:06d}".format(P, j+1)

#print(ans)

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

Submission status: Wrong Answer

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

ans_lst = []
x = 1
tmp_p = None
for p, y, i in PY:
    if p == tmp_p: #属している県が同じ時
        ans_lst.append([p, x, i])
        x += 1
    else:
        ans_lst.append([p, 1, i])
        tmp_p = p
        x = 2

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


#output
for p, x, i in ans_lst:
    ans_p = str('000000') + str(p)
    ans_x = str('000000') + str(x)
    # print (ans_p, ans_x)
    # print (ans_p[-6:])
    print (ans_p[-6:], ans_x[-6:], sep = '')

Submission status: Wrong Answer

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

PiYList = []

for i in range(M):
    P ,Y = map(int, input().split())
    PiYList.append([P, Y, i])

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

tmp = 1
x = 1
for j in range(M):
    if PiYList[j][0] != tmp:
        tmp = PiYList[j][0]
        x = 1
    ans = PiYList[j][0] * 1000000 + x
    ans = str(ans)
    ans = ans.zfill(12)
    PiYList[j][1] = ans
    x += 1

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

for i in range(M):
    print(PiYList[i][1])

Submission status: Wrong Answer

Solution code:
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    from time import time
    start = time()
    N, M = map(int, sys.stdin.readline().split())
    P = [0] * (N + 1)
    C = [0] * M

    for m in range(M):
        p, y = map(int, input().split())
        C[m] = [m, p, y, 0]
    C.sort(key=lambda x :x[2])

    for c in C:
        P[c[1]] += 1
        c[3] = P[c[1]]
    C.sort(key=lambda x :x[3])

    for c in C:
        print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
inl = [[i] + list(map(int,input().split())) for i in range(m)]
inl = sorted(inl,key=lambda x:x[1])
inl = sorted(inl,key=lambda x:x[2])
cnt = 1
for i in range(m):
    a = str(inl[i][1]).rjust(6,"0")
    b = str(cnt).rjust(6,"0")
    cnt +=1
    if i !=m-1 and inl[i][1] != inl[i+1][1]:
        cnt = 1
    inl[i][1] = a
    inl[i][2] = b
inl = sorted(inl,key=lambda x:x[0])
for i in range(m):
    print(str(inl[i][1])+str(inl[i][2]))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
inl = [[i] + list(map(int,input().split())) for i in range(m)]
inl = sorted(inl,key=lambda x:x[1])
inl = sorted(inl,key=lambda x:x[2])
cnt = 1
print(inl)
for i in range(m):
    a = str(inl[i][1]).rjust(6,"0")
    b = str(cnt).rjust(6,"0")
    cnt +=1
    if i !=m-1 and inl[i][1] != inl[i+1][1]:
        cnt = 1
    inl[i][1] = a
    inl[i][2] = b
inl = sorted(inl,key=lambda x:x[0])
for i in range(m):
    print(str(inl[i][1])+str(inl[i][2]))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
inl = [[i] + list(map(int,input().split())) for i in range(m)]
inl = sorted(inl,key=lambda x:x[1])
inl = sorted(inl,key=lambda x:x[2])
cnt = 1
for i in range(m):
    inl[i][1] = str(inl[i][1]).rjust(6,"0")
    inl[i][2] = str(cnt).rjust(6,"0")
    cnt +=1
    if  i!=m-1 and inl[i][1] != inl[i+1][1]:
        cnt = 1

inl = sorted(inl,key=lambda x:x[0])
for i in range(m):
    print(str(inl[i][1])+str(inl[i][2]))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
inl = [[i] + list(map(int,input().split())) for i in range(m)]
inl = sorted(inl,key=lambda x:x[1])
inl = sorted(inl,key=lambda x:x[2])
shi = 1
cnt = 1
for i in range(m):
    if inl[i][1] == shi:
        inl[i][1] = str(shi).rjust(6,"0")
        inl[i][2] = str(cnt).rjust(6,"0")
        cnt +=1
    else:
        shi +=1
        cnt = 1
        inl[i][1] = str(shi).rjust(6,"0")
        inl[i][2] = str(cnt).rjust(6,"0")
        cnt +=1
inl = sorted(inl,key=lambda x:x[0])
for i in range(m):
    print(str(inl[i][1])+str(inl[i][2]))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
inl = [[i] + list(map(int,input().split())) for i in range(m)]
inl = sorted(inl,key=lambda x:x[1])
inl = sorted(inl,key=lambda x:x[2])
shi = 1
cnt = 1
for i in range(m):
    if inl[i][1] == shi:
        inl[i][1] = str(shi).rjust(6,"0")
        inl[i][2] = str(cnt).rjust(6,"0")
        cnt +=1
    else:
        shi +=1
        cnt = 1
        inl[i][1] = str(shi).rjust(6,"0")
        inl[i][2] = str(cnt).rjust(6,"0")
        cnt +=1
inl = sorted(inl,key=lambda x:x[0])
print(inl)
for i in range(m):
    print(str(inl[i][1])+str(inl[i][2]))

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
n,m=map(int,input().split())
py_i=[[int(x) for x in input().split()] for _ in range(m)]
y_p=[[] for i in range(n+1)]
for x,y in sorted(py_i):
    print(x)
    y_p[x].append(y)
for x,y in py_i:
    z=bisect.bisect_right(y_p[x],y)
    print("%06d"%x+"%06d"%z)

#print(y_p)

Submission status: Wrong Answer

Solution code:
import itertools


def solve():
    n, m = map(int, input().split())
    py = list(list(map(int, input().split())) for _ in range(m))
    py_with_key = sorted([(idx, pyi) for idx, pyi in enumerate(py)], key=lambda x: x[1])
    pref_no = 1
    cnt = 0
    ids = []
    for idx, p_y in py_with_key:
        if pref_no == p_y[0]:
            cnt += 1
        else:
            pref_no = p_y[0]
            cnt = 1
        city_id = '{0:06d}{1:06d}'.format(p_y[0], cnt)
        ids.append((idx, city_id))
    print("\n".join([x[1] for x in sorted(ids, key=lambda x: x[0])]))


if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
num=[1]*(n+1)
ansl=[]
for i in range(m):
    p,y=map(int,input().split())
    ans="%06d"%p+"%06d"%num[p]
    num[p]+=1
    ansl.append(ans)
print(*ansl,sep="\n")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in sorted(P):
  z = D[p].index(y)
  print ("%06d%06d"%(p, z+1))

Submission status: Wrong Answer

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

for i in range(m):
  p, y = map(int, input().split())
  l[i][0] = p
  l[i][1] = y
  l[i][2] = i

l.sort()  
#print(l)

c = l[0][0]
x = 0

new_l = [[0, 0] for _ in range(m)]

for j in range(m):
  if l[j][0] != c:
    x = 1
  else:
    x += 1
  new_l[j][0] = str(l[j][0]).zfill(6)+str(x).zfill(6)
  new_l[j][1] = l[j][2]

new_l.sort(key=lambda x: x[1])
for i in range(m):
  print(new_l[i][0])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
lis = [] #市i県ｐ誕生y
ID = [0 for _ in range(m)]
cnt = [0 for _ in range(n)]

for i in range(m):
    p,y = input().split()
    lis.append([i,p,y])
lis = sorted(lis,key = lambda x:x[2])

for i in range(m):
    p = int(lis[i][1])
    cnt[p-1] += 1 #県pで何番目に誕生したか
    up = "0" * (6 - len(lis[i][1])) + str(lis[i][1])
    under = "0" * (6 - len(str(cnt[p-1]))) + str(cnt[p-1])
    ID[lis[i][0]] = up + under
for i in range(m):
    print(ID[i])

Submission status: Wrong Answer

Solution code:
# helper function to change number into 6 digit code
def six(x):
  digit = len(str(x))
  return '0' * (6 - digit) + str(x)

N, M = map(int, input().split())
ans = []
line = 0
while line < M:
    P, C = map(six, input().split())
    line += 1
    ans.append((six(P) + six(C), line))

# sorting by prefecture / city foundation year
ans.sort(key=lambda x:x[0])      

# converting city foundation year to id number
Prefecture = ans[0][0][:6]
cont = 0
for idx in range(M):
  new_Prefecture = ans[idx][0][:6]
  if new_Prefecture != Prefecture:
    cont = 1
  else:
    cont +=1
  ans[idx] = (ans[idx][0][:6] + six(cont), ans[idx][1])
  Prefecture = new_Prefecture

ans.sort(key=lambda x:x[1])
  
for idx in range(M):
  print(ans[idx][0])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
pre = [[] for _ in range(n)]
ID = [0 for _ in range(m)]
for i in range(m):
    p,y = input().split()
    p = int(p)
    pre[p-1].append([i,y])
for i in range(n):
    if pre[i] != []:
        pre[i] = sorted(pre[i], key = lambda x:x[1])
        for j in range(len(pre[i])):
            if pre[i][j] != []:
                up = str(i+1)
                under = str(j+1)
                if len(up) < 6:
                    up = "0" * (6-len(up)) + up
                if len(under) < 6:
                    under = "0" * (6-len(under)) + under
                ID[pre[i][j][0]] = up + under
for i in range(m):
    print(ID[i])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
pre = [[] for _ in range(n)]
ID = [0 for _ in range(m)]
for i in range(m):
    p,y = input().split()
    p = int(p)
    pre[p-1].append([i,y])
for i in range(n):
    if pre[i] != []:
        pre[i] = sorted(pre[i], key = lambda x:x[1])
        for j in range(len(pre[i])):
            if pre[i][j] != []:
                up = str(i+1)
                under = str(j+1)
                up = "0" * (6-len(up)) + up
                under = "0" * (6-len(under)) + under
                ID[pre[i][j][0]] = up + under
for i in range(m):
    print(ID[i])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    a = sorted([[P[i], Y[i]] for i in range(M)], key=lambda x:(x[0],x[1]))
    
    ans = []
    t = -1
    c = 0
    for p,y in a:
        if(p != t):
            t = p
            c = 0
        c += 1
        ans.append(str(p).zfill(6)+str(c).zfill(6))

    for i in ans:
        print(i)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    a = sorted([[P[i], Y[i]] for i in range(M)], key=lambda x:(x[0],x[1]))
    
    ans = []
    t = -1
    c = 0
    for p,y in a:
        if(p != t):
            t = 0
        c += 1
        ans.append(str(p).zfill(6)+str(c).zfill(6))

    for i in ans:
        print(i)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, M, P, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
db = []
line = 0
while line < M:
    P, C = map(int, input().split())
    line += 1
    db.append([line, P, C])

# sort by year    
db.sort(key=lambda x: x[2])
# sort by prefecture
db.sort(key=lambda x: x[1])

# ans list would be list whereby each element is [line, ID]
ans = []

cont = 0
P = db[0][1]

for idx in range(M):
  # create ID
  new_P = db[idx][1]
  
  digP = len(str(new_P))
  
  ID = '0' * (6 - digP) + str(new_P)
  
  if new_P == P:
    cont += 1
  else:
    cont = 1
    
  ID += '0' * (6 - len(str(cont))) + str(cont)
  
  ans.append([db[idx][0],ID])
  
  P = new_P

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

for row in range(M):
  print(ans[row][1])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
db = []
line = 0
while line < M:
    P, C = map(int, input().split())
    line += 1
    db.append([line, P, C])

# sort by year    
db.sort(key=lambda x: x[2])
# sort by prefecture
db.sort(key=lambda x: x[1])

print(db)

# ans list would be list whereby each element is [line, ID]
ans = []

cont = 0
P = db[0][1]

for idx in range(M):
  # create ID
  new_P = db[idx][1]
  
  digP = len(str(new_P))
  
  ID = '0' * (6 - digP) + str(new_P)
  
  if new_P == P:
    cont += 1
  else:
    cont = 1
    
  ID += '0' * (6 - len(str(cont))) + str(cont)
  
  ans.append([db[idx][0],ID])
  
  P = new_P

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

for row in range(M):
  print(ans[row][1])

Submission status: Wrong Answer

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

_number = []
P = []
Y = []
yp = [[] for i in range(N+1)]
_yp = []

for i in range(M):
    p, y = map(int, input().split())
    yp[p].append([y, i])

# print(yp)

_l_yp = len(yp)

for i in range(_l_yp):
    yp[i].sort()


ans_yp = [[] for i in range(M)]

for i in range(_l_yp):
    nga_yp = len(yp[i])

    for j in range(nga_yp):
       print(i, j)
       print(yp[i][j][1])
       ans_yp[yp[i][j][1]].append(i)
       ans_yp[yp[i][j][1]].append(j+1)


__len = len(ans_yp)

for i in range(__len):
    buff = ''
    for d in range(2):
        ans = ''
        for j in range((6-len(str(ans_yp[i][d])))):
            ans += '0'

        buff += ans + str(ans_yp[i][d])

    print(buff)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
h = [list(map(int, input().split()))for i in range(M)]
for i in range(M):
    h[i].append(i)
h = sorted(h,key=lambda h:(h[0],h[1]))
k = 0
for i in range(M):
    if h[i][0] == 1:
        h[i].append("000001")
        h[i].append(str(i+1).zfill(6))
    else:
        h[i].append("000002")
        h[i].append(str(k+1).zfill(6))
        k += 1
h = sorted(h,key=lambda h:h[2])
for i in range(M):
    print(h[i][3]+h[i][4])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
h = [list(map(int, input().split()))for i in range(M)]
for i in range(M):
    h[i].append(i)
h = sorted(h,key=lambda h:(h[0],-h[1]))
k = 0
for i in range(M):
    if h[i][0] == 1:
        h[i].append("000001")
        h[i].append(str(i+1).zfill(6))
    else:
        h[i].append("000002")
        h[i].append(str(k+1).zfill(6))
        k += 1
h = sorted(h,key=lambda h:h[2])
for i in range(M):
    print(h[i][3]+h[i][4])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
pref = [[] for _ in range(n)]
cityrecord = []
for i in range(m):
  p,y = map(int,input().split())
  pref[p-1].append([y,i])
  cityrecord.append(p-1)
for ni in range(n):
  pref[ni].sort()
print(pref)
for i in range(m):
  now = cityrecord[i]
  for j in range(len(pref[now])):
    if pref[now][j][1] == i:
      ans = (now + 1) * 10 ** 6 + j + 1
      ANS = str(ans)
      out = '0' * (12 - len(ANS)) + ANS
      print(out)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n, m = [int(x) for x in input().split(' ')]
py = sorted(
        sorted(
            [input().split(' ') + [i] for i, _ in enumerate(range(m))],
            key=lambda x: int(x[1])
        ),
        key=lambda x: x[2]
    )

d = defaultdict(int)

for p, _, _ in py:
    d[p] += 1
    print(p.zfill(6) + str(d[p]).zfill(6))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n, m = [int(x) for x in input().split(' ')]
py = [tuple(input().split(' ')) for _ in range(m)]

d = defaultdict(list)

for x, y in py:
    d[x].append(int(y))

ans = {}

for k, v in d.items():
    print(k, v)
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)

for x in py:
    print(ans[x])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n, m = [int(x) for x in input().split(' ')]
py = [tuple(input().split(' ')) for _ in range(m)]

d = defaultdict(list)

for x, y in py:
    d[x].append(y)

ans = {}

for k, v in d.items():
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, x)] = k.zfill(6) + str(i).zfill(6)

for x in py:
    print(ans[x])

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(n):
    ol[pl[i]].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(n):
    ol[pl[i]].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], ol[pl[i]].index(yl[i])+1))

Submission status: Wrong Answer

Solution code:
import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(n):
    ol[pl[i]].sort()
for i in range(m):
    x = bisect.bisect_right(ol[pl[i]], yl[i])
    print("%06d%06d" % (pl[i], x))

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
cl=[0]*m
# ppl=[[] for j in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())

# for i in range(m):
#     pl[i],yl[i] = map(int, input().split())
#     ppl[pl[i]].append((yl[i], i))

for i in range(m):
    print("%06d%06d" % (pl[i], cl[i]))

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
cl=[0]*m
ppl=[[] for j in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ppl[pl[i]].append((yl[i], i))

for i in range(m):
    print("%06d%06d" % (pl[i], cl[i]))

Submission status: Wrong Answer

Solution code:
#Coding:Utf-8

N,M=list(map(int, input().split()))
P=[]
Q=[]
for i in range(M):
    P.append(list(map(int,input().split())))
O=sorted(P)

count=order=1
for l in range(M):
    if count!=O[l][0]:
        count=O[l][0]
        order=1
    Q+=O[l][1],order
    order+=1

for n in range(M):
    print(str(P[n][0]).zfill(6)+str(Q[Q.index(P[n][1])+1]).zfill(6))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
city_d = {}
ans_l = ["" for _ in range(M)]
for i in range(M):
    P,Y = map(int,input().split())
    city_d.setdefault(P,[])
    city_d[P].append([Y,i])

for p,y_orgnum in city_d.items():
    for j,sorted_y_orgnum in enumerate(sorted(y_orgnum,key=lambda x:x[0])):
        ans_l[sorted_y_orgnum[1]] = str(p).zfill(8) + str(j+1).zfill(8)

for ans in ans_l:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)


# 市ごとに連続するようにする
sort_ind = p_ar.argsort()
p_sorted = p_ar[sort_ind]
y_sorted = y_ar[sort_ind]
x_ar = np.zeros(len(p_ls))
x_ar_sorted = np.zeros(len(p_ls))

ind = 0

while ind < M:
    d = np.count_nonzero(y_sorted == y_sorted[ind])
    tmp_x = y_sorted[ind:ind+d+1].argsort()+ind
    x_ar_sorted[tmp_x] = np.array(range(len(tmp_x)))+1
    ind = ind + d + 1

x_ar[sort_ind] = x_ar_sorted

for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)


# 市ごとに連続するようにする
p_ind = p_ar.argsort()
p_sorted = p_ar[p_ind]
y_sorted = y_ar[p_ind]
x_ar_sorted = np.zeros(len(p_ls))


ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_sorted[ind] == p_sorted[ind+d+1]:
        d+=1
    tmp_x = y_sorted[ind:ind+d+1].argsort()+1
    x_ar_sorted[ind:ind+d+1] = tmp_x
    ind = ind + d + 1

for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar_sorted[p_ind[i]])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)
x_ar = np.zeros(len(p_ls))

# 市ごとに連続するようにする
p_ind = p_ar.argsort()

ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_ar[p_ind[ind]] == p_ar[p_ind[ind+d+1]]:
        d+=1
    tmp_x = y_ar[p_ind[ind:ind+d+1]].argsort()+1
    x_ar[ind:ind+d+1] = tmp_x
    ind = ind + d + 1
for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[p_ind[i]])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)
x_ar = np.zeros(len(p_ls))

# 市ごとに連続するようにする
p_ind = p_ar.argsort()

ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_ar[p_ind[ind]] == p_ar[p_ind[ind+d+1]]:
        d+=1
    tmp_x = y_ar[p_ind[ind:ind+d+1]].argsort()+1
    x_ar[p_ind[ind:ind+d+1]] = tmp_x
    ind = ind + d + 1
for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)
x_ar = np.zeros(len(p_ls))

# 市ごとに連続するようにする
p_ind = p_ar.argsort()

ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_ar[ind] == p_ar[ind+d+1]:
        d+=1
    tmp_x = y_ar[p_ind[ind:ind+d+1]].argsort()+1
    x_ar[p_ind[ind:ind+d+1]] = tmp_x
    ind = ind + d + 1
for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)
x_ar = np.zeros(len(p_ls))

# 市ごとに連続するようにする
p_ind = p_ar.argsort()

ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_ar[ind] == p_ar[ind+d+1]:
        d+=1
    tmp_x = y_ar[ind:ind+d+1].argsort()+1
    x_ar[p_ind[ind:ind+d+1]] = tmp_x
    ind = ind + d + 1
for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[i])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p_ls = []
y_ls = []
for _ in range(M):
    p,y = map(int,input().split(" "))
    p_ls.append(p)
    y_ls.append(y)

p_ar = np.array(p_ls)
y_ar = np.array(y_ls)
x_ar = np.zeros(len(p_ls))

# 市ごとに連続するようにする
p_ind = p_ar.argsort()

ind = 0

while ind < M:
    d = 0
    while ind+d < M-1 and p_ar[ind] == p_ar[ind+d+1]:
        d+=1
    tmp_x = p_ar[ind:ind+d+1].argsort()+1
    x_ar[p_ind[ind:ind+d+1]] = tmp_x
    ind = ind + d + 1
for i in range(M):
    print('%06d'%p_ar[i] + '%06d'%x_ar[i])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M
check = [[] for i in range(N)]

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
dict_ = {i:tuple(input().split()) for i in range(m)}

sorted_dict = sorted(dict_.items(), key=lambda x: x[1])

res = {}
tmp = ''
cnt = 0
for item in sorted_dict:
    if item[1][0] == tmp:
        cnt += 1
    else:
        tmp = item[1][0]
        cnt = 1
    res[item[0]] = item[1][0].zfill(6) + str(cnt).zfill(6)

for i in sorted(res.items()):
    print(i[1])

Submission status: Wrong Answer

Solution code:
N,M = [int(n) for n in input().split()]
o = {}
a = []
for i in range(M):
    p,y = [int(n) for n in input().split()]
    a.append((p, y))
    if p in o:
        o[p].append(y)
    else:
        o[p] = [y]
sa = {k:sorted(o[k]) for k in o}
for ans in ((t[0], sa[t[0]].index(t[1])+1) for t in a):
    print(str(ans[0]).zfill(6),str(ans[1]).zfill(6))

Submission status: Wrong Answer

Solution code:
import copy

n,m = map(int,input().split())
py = [list(map(int,input().split())) for _ in range(m)]

py_sorted = copy.deepcopy(py)
py_sorted = sorted(py_sorted,key=lambda x :(x[1],x[0]))

id_y = {}
pref_id= py_sorted[0][0]
city_id=1

for e in py_sorted:
  if pref_id != e[0]:
    pref_id = e[0]
    city_id =1
  id_y['{}_{}'.format(e[0],e[1])] = '{:06d}{:06d}'.format(e[0],city_id)
  city_id += 1
  
for pyi in py:
  print(id_y['{}_{}'.format(pyi[0],pyi[1])])

Submission status: Wrong Answer

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

p_count = [1] * (N + 1)
for r in sorted(pairs, key=lambda x: x[1]):
    r.append("{:06}{:06}".format(r[0], p_count[r[0]]))
    p_count[r[0]] += 1
print(pairs)

print("\n".join((r[2] for r in pairs)))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[list(map(int, input().split())) for i in range(m)] 
for i in range(m):
    s[i].append(i+1)
a=0
s.sort(key=lambda x:(x[0], x[1]))
for i in range(m):
    if i>=1:
        if s[i][0]!=s[i-1][0]:
            a=0
        
    s[i].append(str(0)*(6-len(str(s[i][0])))+str(s[i][0]))
    s[i].append(str(0)*(6-len(str(a)))+str(a+1))
    a+=1
s.sort(key=lambda x:x[2])
for i in range(m):
    print(s[i][3]+s[i][4])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[list(map(int, input().split())) for i in range(m)] 
for i in range(m):
    s[i].append(i+1)
a=0
s.sort()
for i in range(m):
    if i>=1:
        if s[i][0]>s[i-1][0]:
            a=0
        
    s[i].append(str(0)*(6-len(str(s[i][0])))+str(s[i][0]))
    s[i].append(str(0)*(6-len(str(a)))+str(a+1))
    a+=1
s.sort(key=lambda x:x[2])
for i in range(m):
    print(s[i][3]+s[i][4])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[list(map(int, input().split())) for i in range(m)] 
for i in range(m):
    s[i].append(i+1)
a=0
s.sort()
for i in range(m):
    if i>=1:
        if s[i][0]!=s[i-1][0]:
            a=0
        
    s[i].append(str(0)*(6-len(str(s[i][0])))+str(s[i][0]))
    s[i].append(str(0)*(6-len(str(a)))+str(a+1))
    a+=1
s.sort(key=lambda x:x[2])
for i in range(m):
    print(s[i][3]+s[i][4])