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:
def nyu():
    N, M = map(int, input().split())
    S = [list(input().split()) for i in range(M)]
    return N,M,S

def kansu(N,M,S):

    S_tmp=[]
    for i in range(M):
        tmp = [int(S[i][0]),int(S[i][1]),0]
        S_tmp.append(tmp) 
    S_tmp.sort()

    tmp = S_tmp[0][0]
    cnt = 1

    for i in range(M):
        if tmp == S_tmp[i][0]:
            S_tmp[i][2] = cnt
            cnt += 1
        else :
            cnt = 1
            tmp = S_tmp[i][0]
            S_tmp[i][2] = cnt
    
    for i in range(M):
        for n in range(M):
        #    print("S[i][1]=",S[i][1],"S_tmp[n][1]=",S_tmp[n][1])
            if int(S[i][1]) == int(S_tmp[n][1]):
                print(str(S[i][0]).zfill(6),str(S_tmp[n][2]).zfill(6),sep='')
                break

    # for m1 in range(M):
    #     cnt = 1
    #     tmp_m1 = S[m1][0]
    #     tmp_m2 = S[m1][1]
    #     for m2 in range(M):
    #         if S[m2][0] == tmp_m1 and S[m2][1] < tmp_m2:
    #             cnt = cnt + 1
    #     print(str(S[m1][0]).zfill(6),str(cnt).zfill(6),sep='')


N,M,S = nyu()
kansu(N,M,S)
#print(S)

Submission status: Wrong Answer

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

def kansu(N,M,S):

    S_tmp=[]
    for i in range(M):
        tmp = [int(S[i][0]),int(S[i][1]),0]
        S_tmp.append(tmp) 
    S_tmp.sort()

    tmp = S_tmp[0][0]
    cnt = 1

    for i in range(M):
        if tmp == S_tmp[i][0]:
            S_tmp[i][2] = cnt
            cnt += 1
        else :
            cnt = 1
            S_tmp[i][2] = cnt
    
    for i in range(M):
        for n in range(M):
        #    print("S[i][1]=",S[i][1],"S_tmp[n][1]=",S_tmp[n][1])
            if int(S[i][1]) == int(S_tmp[n][1]):
                print(str(S[i][0]).zfill(6),str(S_tmp[n][2]).zfill(6),sep='')
                break

    # for m1 in range(M):
    #     cnt = 1
    #     tmp_m1 = S[m1][0]
    #     tmp_m2 = S[m1][1]
    #     for m2 in range(M):
    #         if S[m2][0] == tmp_m1 and S[m2][1] < tmp_m2:
    #             cnt = cnt + 1
    #     print(str(S[m1][0]).zfill(6),str(cnt).zfill(6),sep='')


N,M,S = nyu()
kansu(N,M,S)
#print(S)

Submission status: Wrong Answer

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

def kansu(N,M,S):
    # N_counter =  [[0] * 2 for i in range(N)]
    
    # for n in range(N):
    #     N_counter[n][0] = n
    

    for m1 in range(M):
        cnt = 1
        tmp_m1 = S[m1][0]
        tmp_m2 = S[m1][1]
        for m2 in range(M):
            if S[m2][0] == tmp_m1 and S[m2][1] < tmp_m2:
                cnt = cnt + 1
        print(str(S[m1][0]).zfill(6),str(cnt).zfill(6),sep='')


N,M,S = nyu()
kansu(N,M,S)
#print(S)

Submission status: Wrong Answer

Solution code:
from collections import deque
import bisect
x,y=map(int,input().split())
citylist=deque([deque() for x in range(x)])
inputlist=deque()
arucity=deque()
old=0
for a in range(y):
    s,t=map(int,input().split())
    citylist[s-1].append(t)
    inputlist.append(s)
    inputlist.append(t)
    if old != s:
        arucity.append(s)
        old = s

for a in arucity:
    citylist[a-1]=sorted(citylist[a-1])
for b in range(y):
    e=inputlist.popleft()
    print("{:06}{:06}".format(e,(bisect.bisect(citylist[e-1],inputlist.popleft())+1)))

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
citylist=[[] for x in range(x)]
inputlist=[]
arucity=set()
for a in range(y):
    s,t=map(int,input().split())
    citylist[s-1].append(t)
    inputlist.append(s)
    inputlist.append(t)
    arucity.add(s)
for a in arucity:
    citylist[a-1].sort()
for b in range(y):
    e=inputlist.pop(0)
    print("{:08} {:08}".format(e,(citylist[e-1].index(inputlist.pop(0))+1)))

Submission status: Wrong Answer

Solution code:
from collections import deque
x,y=map(int,input().split())
citylist=deque([[] for x in range(x)])
inputlist=deque()
arucity=set()
for a in range(y):
    s,t=map(int,input().split())
    citylist[s-1].append(t)
    inputlist.append(s)
    inputlist.append(t)
    arucity.add(s)
for a in arucity:
    citylist[a-1].sort()
for b in range(y):
    e=inputlist.popleft()
    print("{:08}{:08}".format(e,(citylist[e-1].index(inputlist.popleft())+1)))

Submission status: Wrong Answer

Solution code:
from collections import deque
x,y=map(int,input().split())
citylist=deque([[] for x in range(x)])
inputlist=deque()
arucity=set()
for a in range(y):
    s,t=map(int,input().split())
    citylist[s-1].append(t)
    inputlist.append(s)
    inputlist.append(t)
    arucity.add(s)
for a in arucity:
    citylist[a-1].sort()
for b in range(y):
    e=inputlist.popleft()
    print("{:08} {:08}".format(e,(citylist[e-1].index(inputlist.popleft())+1)))

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
citylist=[[] for x in range(x)]
inputlist=[]
for a in range(y):
    s,t=map(int,input().split())
    citylist[s-1].append(t)
    inputlist.append(s)
    inputlist.append(t)
for a in citylist:
    a.sort()
for b in range(y):
    e=inputlist.pop(0)
    print("{:08} {:08}".format(e,(citylist[e-1].index(inputlist.pop(0))+1)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
base = []
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base.append([p,y])
  base_1.append([p,y])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  print(p_str + count)

Submission status: Wrong Answer

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

PY.sort(key=lambda x:x[1])
#print(PY)

prefecture=[[] for _ in range(N)]
for el in PY:
    p, y = el
    prefecture[p-1].append(y)
#print(prefecture)

for j, p in enumerate(prefecture):
    for i, city in enumerate(p):
        print(str(j+1).zfill(6) + str(i+1).zfill(6))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
d=[0]*M
res = []
for i in range(M):
    P,Y = map(int,input().split())
    res.append((P,Y,i))
c=1
print(res)
for i in sorted(res):
    x = str(i[0])
    y = str(i[1])
    tmp = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)
    if(tmp in d):
        c+=1
        d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)
    else:
        c = 1
        d[i[2]] = (6-len(x))*'0'+x+(6-len(str(c)))*'0'+str(c)

for i in d:
    print(i)

Submission status: Wrong Answer

Solution code:
def main():
    n, m, *py = map(int, open(0).read().split())
    d = [[] for _ in range(n + 1)]

    for i, j in zip(*[iter(py)] * 2):
        d[i].append(j)

    ans = ''
    d = tuple(d)
    for i, j in zip(*[iter(py)] * 2):
        k = d[i].index(j) + 1
        id = str(i).zfill(6) + str(k).zfill(6)
        ans += id + '\n'

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
py = [LI()+[i] for i in range(m)]

py.sort(key = lambda x:(x[0],x[1]))
ans = []
flag = True
cnt = 0
for p,y,i in py:
    s = '0'*6
    t = '0'*6
    if flag:
        cnt += 1
        tmp = p
        flag = False
    elif tmp == p:
        cnt += 1
    else:
        cnt = 1
    s += str(p)
    s = s[-6:]
    t += str(cnt)
    t = t[-6:]
    ans.append([s+t,i])
ans.sort(key = lambda x:x[1])
for i,j in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
PYlist = []
for i in range(M):
    PYlist_ele = list(map(int,input().split()))
    PYlist_ele.append(i+1)
    PYlist.append(PYlist_ele)
PYlist.sort()
check = 0
count = 0
P_id = []
for i in range(M):
    if check == PYlist[i][0]:
        count +=1
    else:
        count = 1
    idup = '{:06}'.format(PYlist[i][0])
    iddown = '{:06}'.format(check)
    P_id.append([str(idup)+str(iddown),PYlist[i][2]])
P_id.sort(key=lambda x: x[1])
for ans in P_id:
    print(ans[0])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
cities = []
number = [[] for i in range(n)]
for i in range(m):
  n, id = map(int, input().split())
  cities.append([n, id])
  number[n-1].append(id)

for i in range(n):
  number[i].sort()

for i in range(m):
  tmp = number[cities[i][0]-1].index(cities[i][1])
  print(format(cities[i][0], '06') + format(tmp+1, '06'))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
p_y_num_list = [list(map(int, input().split())) + [i] for i in range(m)]
p_y_num_list_sort = sorted(p_y_num_list, key=lambda x: x[0])
p_y_num_list_sort = sorted(p_y_num_list_sort)
now = p_y_num_list_sort[0][0]
num = 1
for pyn in p_y_num_list_sort:
    if pyn[0] != now:
        num = 1
        now = pyn[0]
        pyn.append(num)
    else:
        pyn.append(num)
        num += 1
p_y_num_list_sort.sort(key=lambda x: x[2])
for p, y, i, n in p_y_num_list_sort:
    print("{:06}{:06}".format(p, n))

Submission status: Wrong Answer

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

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

city_list.sort(key=lambda x: (x[0], x[1],))

#print(city_list)

tmp_list = [0]*m
tmp_num = 1
for num,j in enumerate(city_list):
    if num == 0:
        tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
        j_tmp = j[0]
        tmp_num += 1
    else:
        if j[0] != j_tmp:
            tmp_num = 1
            tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
        else:
            tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)
            tmp_num += 1

for k in tmp_list:
    print(k)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append([b,i])
ans=[0]*m
for idx,i in enumerate(l,1):
    i.sort(key=lambda x:x[0])
    pref=''
    if len(str(idx))<6:
        diff=6-len(str(idx))
        pref=('0'*diff)+str(idx)
    #print(i)
    for j,k in enumerate(i,1):
        suff=''
        if len(str(j))<6:
            diff=6-len(str(j))
            suff=('0'*diff)+str(j)
#        print(k[1])
        ans[k[1]]=pref+suff
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
li = []
for i in range(m):
    p,y = map(int,input().split())
    li.append([p,y,i])
li.sort(key=lambda x:x[0])
li.sort(key=lambda x:x[1])
pre = li[0][0]
cnt = 1
ans = []
for p,y,i in li:
    if p==pre:
        ans.append((str(p).zfill(6) + str(cnt).zfill(6) ,i))
        cnt+=1
    else:
        pre = p
        ans.append((str(p).zfill(6) + str(1).zfill(6),i))
        cnt=2
ans.sort(key=lambda x:x[1])
for a,i in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import numpy as np

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

list_ans = []
list_y = []
pre_p = -1
p_y = defaultdict(list)

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

for p in p_y.keys():
    list_y = p_y[p]
    list_num = np.argsort(list_y)
    for num in list_num:
        ans = str(p).zfill(6) + str(num + 1).zfill(6)
        print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ls = []
for i in range(m):
    p,y = map(int,input().split())
    ls.append([p,y])
ls.sort(key= lambda x:x[1])
ls.sort(key= lambda x:x[0])
pre = ls[0][0]
cnt = 1
for p,y in ls:
    if p==pre:
        print(str(p).zfill(6) + str(cnt).zfill(6))
        cnt+=1
    else:
        pre = p
        print(str(p).zfill(6) + str(1).zfill(6))
        cnt=2

Submission status: Wrong Answer

Solution code:
from sys import stdin

N, M = map(int, stdin.readline().split())
py = [list(map(int, stdin.readline().split())) for _ in range(M)]

py.sort()

px = []

ptmp = 0
xtmp = 1

for p, y in py:
    if p == ptmp:
        xtmp += 1
        px.append([p, xtmp])
    else:
        ptmp = p
        xtmp = 1
        px.append([p, xtmp])

for p, x in px:
    print("{0:06d}".format(p), "{0:06d}".format(x), sep="")

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N,M = map(int,input().split())
PY = {n: [] for n in range(N + 1)}
ans = [0]*M
for i in range(M):
  p,y = map(int,input().split())
  PY[p].append((y, i))
print(PY)
for p,y in PY.items():
  y.sort()
  for j, (z, i) in enumerate(y):
    top_number = '0'*(6-len(str(p)))+str(p)
    under_number = '0'*(6-len((str(j+1))))+str(j+1)
    ans[i] = top_number + under_number
for i in range(M):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N,M = map(int,input().split())
PY = {n: [] for n in range(N + 1)}
for i in range(M):
  p,y = map(int,input().split())
  PY[p].append((y, i))
print(PY)
for p,y in PY.items():
  y.sort()
  for j, (z, i) in enumerate(y):
    top_number = '0'*(6-len(str(p)))+str(p)
    under_number = '0'*(6-len((str(j+1))))+str(j+1)
    print(top_number + under_number)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
py = sorted([list(map(int,input().split()))+[i] for i in range(m)])
cnt = 1
ans_list = [['0'*(6 - len(str(m)))+str(py[0][0])+'000001',py[0][2]]]
for i in range(1,m):
  ans = '0'*(6 - len(str(py[i][0])))
  ans += str(py[i][0])
  if py[i-1][0] == py[i][0]:
    cnt += 1
  else:
    cnt = 1
  ans += '0'*(6 - len(str(cnt)))
  ans += str(cnt)
  ans_list.append([ans,py[i][2]])
ans_list = sorted(ans_list,key=lambda x:x[1])
for i in ans_list:
  print(i[0])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
py = sorted([list(map(int,input().split()))+[i] for i in range(m)])
cnt = 1
ans_list = [['0'*(6 - len(str(m)))+str(py[0][0])+'000001',py[0][2]]]
for i in range(1,m):
  ans = '0'*(6 - len(str(m)))
  ans += str(py[i][0])
  if py[i-1][0] == py[i][0]:
    cnt += 1
  else:
    cnt = 1
  ans += '0'*(6 - len(str(cnt)))
  ans += str(cnt)
  ans_list.append([ans,py[i][2]])
ans_list = sorted(ans_list,key=lambda x:x[1])
for i in ans_list:
  print(i[0])

Submission status: Wrong Answer

Solution code:
import sys
import collections
import copy
from bisect import bisect_left,bisect
input = sys.stdin.readline
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
PY_copy = copy.deepcopy(PY)
PY_copy.sort()
pc = []
yc = []
for i in range(M):
  pc.append(PY_copy[i][0])
  yc.append(PY_copy[i][1])
for p,y in PY:
  start = bisect_left(pc,p)
  end = bisect(pc,p)
  top_number = '0'*(6-len(str(p+1)))+str(p)
  for i in range(start,end):
    if y == yc[i]:
      under_number = '0'*(6-len((str(i-start+1))))+str(i-start+1)
  print(top_number + under_number)

Submission status: Wrong Answer

Solution code:
import sys

# import bisect
# from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))
    pyir = [[0] * 4 for _ in range(m)]

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

    pyir.sort(key=itemgetter(0))
    pyir.sort(key=itemgetter(1))

    x = 0
    pprev = pyir[0][0]

    for i in range(m):
        if pprev != pyir[i][0]:
            x = 0
        x += 1
        pyir[i][3] = str(pyir[i][0]).zfill(6) + str(x).zfill(6)
        pprev = pyir[i][0]

    pyir.sort(key=itemgetter(2))

    for i in range(m):
        print(pyir[i][3])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

city = []
for i in range(m):
    p, y = map(int, input().split())
    city.append([i + 1, p, y])
city = sorted(city, key=lambda x: x[2])

res = []
p, pp = 0, 0
cnt = 0
for i in range(m):
    idx, p, _ = city[i]
    if i == 0:
        cnt = 1
        pp = p
    elif pp == p:
        cnt += 1
    else:
        pp = p
        cnt = 1

    ID = str(p).rjust(6, '0') + str(cnt).rjust(6, '0')
    res.append([idx, ID])

res = sorted(res, key=lambda x: x[0])
for i in res:
    print(i[1])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
x = []
for i in range(m):
    p, y = map(int, input().split())
    x.append([i, p, y])
x.sort(key = lambda x : x[1])
c = x[0][1]
d = 0
ans = []
for i in range(m):
    if not x[i][1] == c:
        z = x[d : i]
        z.sort(key = lambda x : x[2])
        for j in range(i - d):
            z[j][2] = j + 1
        ans = ans + z
        d = i
z = x[d : m]
z.sort(key = lambda x : x[2])
for j in range(m - d):
    z[j][2] = j + 1
ans = ans + z
ans.sort()
for i in range(m):
    s = str(ans[i][1])
    t = str(ans[i][2])
    ss = ["0" for _ in range(6 - len(s))]
    tt = ["0" for _ in range(6 - len(t))]
    print("".join(ss), end = "")
    print(s, end = "")
    print("".join(tt), end = "")
    print(t)

Submission status: Wrong Answer

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

list_PY.sort(key=lambda x:(x[0], x[1]))
cnt = 0
k = 0

for i in range(m):
    list_P = ["0" for _ in range(6)]
    list_X = ["0" for _ in range(6)]
    l = list_PY[i]
    if l[0] == k:
        cnt += 1
        a = list(str(l[0]))
        b = list(str(cnt))
        for j in range(1, len(a)+1):
            list_P[-j] = a[-j]
        for j in range(1, len(b)+1):
            list_X[-j] = b[-j]
    else:
        k = l[0]
        cnt = 1
        a = list(str(l[0]))
        b = list(str(cnt))
        for j in range(1, len(a)+1):
            list_P[-j] = a[-j]
        for j in range(1, len(b)+1):
            list_X[-j] = b[-j]

    c = list_P + list_X
    ans = "".join(c)
    print(ans)

Submission status: Wrong Answer

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

data = []

for _ in range(m):
    temp_p, temp_y = input().split()
    temp_p, temp_y = int(temp_p), int(temp_y)
    data.append([temp_p, temp_y])

data.sort()

result = []

for temp_data in data:
    result.append("{:0>6}".format(temp_data[0]) + "{:0>6}".format(temp_data[1]))

for s in result:
    print(s)

Submission status: Wrong Answer

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

data = []

for _ in range(m):
    temp_p, temp_y = input().split()
    temp_p, temp_y = int(temp_p), int(temp_y)
    data.append([temp_p, temp_y])

data.sort()

result = ""

for temp_data in data:
    result += "{:0>6}".format(temp_data[0]) + "{:0>6}".format(temp_data[1]) + "\n"

print(result)

Submission status: Wrong Answer

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


def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) // 2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1


n, m = map(int, input().split())
py = [list(map(int, input().split())) for i in range(m)]
check = sorted(py)
memo = py[0][0]
cnt = [0] * m
cnt_memo = 0

for i in range(m):
    if memo != check[i][0]:
        cnt_memo = 0
    cnt_memo += 1
    cnt[i] = cnt_memo

for i in range(m):
    number = str(cnt[binary_search(check, py[i])])
    p = str(py[i][0])
    print((6 - len(p)) * '0' + p + (6 - len(number)) * '0' + number)

Submission status: Wrong Answer

Solution code:
ken, city = map(int,input().split())
grid = []
for i in range(city):
    array = list(map(int, input().strip().split()))
    grid.append(array)

grid.sort()

for i in range(city):
    print(str(grid[i][0]).zfill(6),str(grid[i][1]).zfill(6),sep="")

Submission status: Wrong Answer

Solution code:
from sys import stdin
def f(n,m):
    n,m=str(n),str(m)
    s1=["0"]*(6-len(n))
    s1.append(n)
    s2=["0"]*(6-len(m))
    s2.append(m)
    return "".join(s1)+"".join(s2)

def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    li=[0]*M
    for i in range(M):
        a=list(map(int,readline().split()))
        a.append(i)
        li[i]=a
    
    li.sort(key=lambda x:x[1])
    print(li)
    count=[1]*(N+1)
    for i in range(M):
        city_number=li[i][0]
        x=count[city_number]
        count[city_number]+=1
        li[i].append(f(city_number,x))

    li.sort(key=lambda x:x[2])
    for i in range(M):
        print(li[i][3])
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:

n, m = map(int, input().split())
data = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    data[p - 1].append([y, i])

ans = [None] * m
for i in  range(n):
    data[i].sort()
    for j in range(len(data[i])):
        y, k = data[i][j]
        print(k)
        ans[k] = '0' * (6 - len(str(i + 1))) + str(i + 1) + '0' * (6 - len(str(j + 1))) + str(j + 1)

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

Submission status: Wrong Answer

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

CITYID = 2
PREF = 0
YEAR = 1
city = [[int(x) for x in input().split()] + [i] for i in range(M)]

city.sort()

id = [""] * M
for i in range(M):
    print(city[i])

ord = 1 # 同じ県の中の順番
for i in range(M):
    if i > 0 and city[i][PREF] == city[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    id[city[i][CITYID]] = '{:0>6}{:0>6}'.format(str(city[i][PREF]),  str(ord))

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

Submission status: Wrong Answer

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

PREF = 0
YEAR = 1
PY = [tuple(int(x) for x in input().split()) for _ in range(M)]

PY.sort()

ord = 1 # 同じ県の中の順番
for i in range(M):
    if i > 0 and PY[i][PREF] == PY[i - 1][PREF]:
        ord += 1
    else:
        ord = 1
    print('{:0>6}{:0>6}'.format(str(PY[i][PREF]),  str(ord)))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
P = []
for i in range(M) :
    p, y = map(int,input().split())
    P.append([p, y, i])

P.sort(key = lambda x: (x[0],x[1]))
print(P)

ans = [0 for i in range(M)]
count = 1

for i in range(M) :
    num = P[i][2]
    if i > 0 :
        if P[i][0] == P[i-1][0] :
            count += 1
        else :
            count = 1
    ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)

for t in ans :
    print(t)

Submission status: Wrong Answer

Solution code:
def input_int_list():
    return [int(thing) for thing in input().split(" ")]
N,M=input_int_list()
ken_toshi=[input_int_list() for _ in range(M)]
ken_shinotoshi={i+1:sorted([thing[1] for thing in ken_toshi if thing[0]==i+1]) for i in range(N)}
ken_toshinum={i+1:0 for i in range(N)}
def normalize(num:int):
    return str(num).zfill(6)

for ken,toshi in ken_toshi:
    ans_left=normalize(ken)
    the_index=ken_shinotoshi[ken].index(toshi)
    ken_shinotoshi[ken].pop(the_index)
    ans_right=normalize(the_index+1+ken_toshinum[ken])
    print(ans_left+ans_right)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = [int(i) for i in input().split()]
p = np.zeros(m,dtype=int)
y = np.zeros(m,dtype=int)
for i in range(m):
    p[i],y[i] = [int(i) for i in input().split()]
for n in set(p):
    y[np.where(p == n)] = np.where(np.sort(y[p == n]))
for i in range(m):
    print(str(p[i]).zfill(6) + str(y[i]).zfill(6))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
py = [list(map(int,input().split()))+[_] for _ in range(m)]
py.sort(key = lambda py:py[1])
flag = py[0][0]
flag_2 = 1
for i in range(m):
  if flag != py[i][0]:
    flag = py[i][0]
    flag_2 = 1
  py[i][0] = (6-len(str(py[i][0])))*"0"+str(py[i][0])
  py[i][1] = (6-len(str(flag_2)))*"0"+str(flag_2)
  flag_2 += 1
py.sort(key = lambda py:py[2])
for j in range(m):
  print("".join(py[j][:2]))

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n,m = map(int,input().split())
lists = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    lists[i].append(i)
sort_lists = sorted(lists,key=itemgetter(1))
cnt = 1
ans = []
for i in range(m-1):
    tmp = sort_lists[i][0]
    left =  '{0:06d}'.format(tmp)
    right = '{0:06d}'.format(cnt)
    if tmp == sort_lists[i+1][0]:
        cnt += 1
    else:
        cnt = 1
    ans.append([str(left) + str(right),sort_lists[i][2]] )
tmp = sort_lists[-1][0]
left = '{0:06d}'.format(tmp)
right = '{0:06d}'.format(cnt)
ans.append([str(left) + str(right), sort_lists[-1][2] ])
ans.sort(key = itemgetter(1))
for i in range(m):
    print(ans[i][0])

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
PY=dict()
cnt=[]
for _ in range(M):
    P,Y=map(int,input().split())
    tmp=[P,Y]
    if((P in PY.keys())==False):
        cnt.append(tmp)
        PY[P]=[Y]
    else:
        cnt.append(tmp)
        PY[P].append(Y)


for i in PY.keys():
    PY[i].sort()


for n in cnt:
    p,y=n[0],n[1]
    v=PY[p].index(y)
    PY[p].pop(v)
    print('{:06}{:06}'.format(p,(v+1)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
PY=dict()
cnt=[]
for _ in range(M):
    P,Y=map(int,input().split())
    tmp=[P,Y]
    if((P in PY.keys())==False):
        cnt.append(tmp)
        PY[P]=[Y]
    else:
        cnt.append(tmp)
        PY[P].append(Y)


for i in PY.keys():
    PY[i].sort()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
PY=dict()
for _ in range(M):
    P,Y=map(int,input().split())
    if((P in PY.keys())==False):
        PY[P]=[Y]
    else:
        PY[P].append(Y)
for i in PY.keys():
    for j in range(1,len(PY[i])+1):
        print('{:06}{:06}'.format(i,j))

Submission status: Wrong Answer

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

py = sorted(py, key=lambda x:x[1])
py = sorted(py, key=lambda x:x[0])
#print(py)

ans = [[0] * 2 for i in range(m)]
cnt = 0
val = py[0][2]
for i in range(m):
    if py[i][2] != val:
        cnt = 0
    cnt += 1

    ans[py[i][2]][0] = py[i][0]
    ans[py[i][2]][1] = cnt
#print(ans)
for i in range(m):
    print('0' * (6 - len(str(ans[i][0]))) + str(ans[i][0]) + '0' * (6 - len(str(ans[i][1]))) + str(ans[i][1]))

Submission status: Wrong Answer

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

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

for i in range(N):
  pref[i] = sorted(pref[i])

orders = [0] * N

for i in range(M):
  p = id[i][0]
  y = id[i][1]
  orders[p - 1] += 1
  order = str(orders[p - 1])
  city = str(p)
  ID = ""
  ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order
  print(ID)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]
#print(l)
l = sorted(l)
#print(n,m)
#print(l)

x = l[0][0]
y = 1
#print(x)

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]
#print(l)
l = sorted(l, key=lambda x:(x[1]))
#print(l)
#l = list(reversed(l))
#print(l)
z = []
for j in range(m):
    z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))
#z.sort()
for k in range(m):
    print(z[k])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]
#print(l)
l = sorted(l)
#print(n,m)
#print(l)

x = l[0][0]
y = 1
#print(x)

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]
#print(l)
l = sorted(l, key=lambda x:(x[1]))
#print(l)
l = list(reversed(l))
#print(l)
z = []
for j in range(m):
    z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))
#z.sort()
for k in range(m):
    print(z[k])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
l = [list(map(int, input().split(' '))) for _ in range(m)]
l = sorted(l)
#print(n,m)
#print(l)

x = l[0][0]
y = 1
#print(x)

for i in range(m):
    if l[i][0] == x:
        l[i][1] = y
        y += 1
    else:
        y = 1
        l[i][1] = y
        y += 1
        x = l[i][0]
#print(l)

for j in range(m):
    print(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
c = {}
for _ in range(m):
    p, y = map(int,input().split())
    if p in c:
        c[p] += 1
    else:
        c[p] = 1
cs = sorted(c.items(), key=lambda x:x[0])
for i in cs:
    for j in range(i[1]):
        print(str(i[0]).zfill(6) + str(j+1).zfill(6))