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 copy
n, m = map(int, input().split())
s = []
for i in range(m):#h:高さ
    s.append([int(i) for i in input().split()])
    #l2 = l[:]
t = s[:]
t.sort()
t.sort(key=lambda x: x[1])
co = 1
for i in range(m):
    if i != 0:
        if t[i][0] != t[i - 1][0]:
            co = 1
    if t[i][0] <10:
        moji1 = "00000" + str(t[i][0])
    elif t[i][0] <100:
        moji1 = "0000" + str(t[i][0])
    elif t[i][0] <1000:
        moji1 = "000" + str(t[i][0])
    elif t[i][0] <10000:
        moji1 = "00" + str(t[i][0])
    elif t[i][0] <100000:
        moji1 = "0" + str(t[i][0])
    else:
        moji1 = str(t[i][0])

    if co <10:
        moji2 = "00000" + str(co)
    elif co <100:
        moji2 = "0000" + str(co)
    elif co <1000:
        moji2 = "000" + str(co)
    elif co <10000:
        moji2 = "00" + str(co)
    elif co <100000:
        moji2 = "0" + str(co)
    else:
        moji2 = str(co)
    t[i].append(moji1 + moji2)

for i in range(m):
    print(s[i][2])

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int,input().split())
data=[]
for i in range(M):
    data.append(list(map(int,input().split(" "))))

arr = np.array(data)
c1=np.arange(0,M)
arr=np.insert(arr,2,c1,axis=1)
#arr_sort=arr[np.argsort(arr[:,0])]
arr_sort=arr[np.argsort(arr[:,1])]
arr_sort=arr_sort[np.argsort(arr_sort[:,0])]

j=1
i_prev=1
res=[]
k = 0
for i in arr_sort:
    if(int(i[0])!=i_prev):
        j=1
    #print("{:06}{:06}".format(i[0],j))
    test = "{:06}{:06}".format(i[0],j)
    arr_sort[k][1]= str(test)
    k+=1
    j+=1
    i_prev=i[0]

arr_sort=arr_sort[np.argsort(arr_sort[:,0])]
for i in arr_sort:
    print("{:012}".format(i[1]))

Submission status: Wrong Answer

Solution code:

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

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

x = [0]*N
x[:] = map(int, input().split())
"""


N, M = map(int, input().split())
P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
city_list = [[0, 0, 0, 0, 0]]*M
for m in range(M):
    city_list[m] = [P[m], Y[m], 0, 0, m]
city_list.sort()
i = 1
city_id = [0]*M
cnt = 1
for m in range(M):
    if city_list[m][0] == i:
        city_id[m] = cnt
        cnt += 1
    else:
        i += 1
        cnt = 1
        city_id[m] = cnt
        cnt += 1
    city_list[m][2] = city_id[m]
    city_list[m][3] = int(math.log10(city_list[m][0]) + 1)    
    
city_list.sort(key=itemgetter(4), reverse=False)
ID = ["0"]*M
for m in range(M):
    tmpID = 10**6*city_list[m][0]+city_list[m][2]
    ID[m] = "0"*(6-city_list[m][3])  + str(tmpID)
    print(ID[m])

Submission status: Wrong Answer

Solution code:
"""
Atcoder国には N 個の県があり、これらの県には合計で M 個の市が属しています。
市 i が誕生したのは Yi 年であり、県 Pi に属しています。
ただし、同じ年に誕生した市が複数存在することはないとします。
それぞれの市に 12 桁の認識番号を割り振ることとなりました。
市 i が 県 Pi に属する市の中で x 番目に誕生した市のとき、
市 i の認識番号の上 6 桁は Pi、下 6 桁は x となります。
ただし、Pi や x が 6 桁に満たない場合は 6 桁になるまで 0 を左に追加するものとします。
全ての市の認識番号を求めてください。
ただし、市が 1 つも属さない県がある場合に注意してください。
"""
[n,m] = [int(i) for i in input().split()]
results = {}
another = {}
number = []
c = {}
results2 = {}

for i in range(m):
    [a,b] = [int(j) for j in input().split()]
    if a not in results:
        results[a] = {}
    results[a][i] = b
    another[i] = a

#print(results)
#print(another)
#print(c)
cnt = []
f = {}

for i in range(m):
    former = str(another[i])
    if len(former) < 6:
        former = "0" *(6 - len(former))+former
    #print(former)
    if another[i] not in results2:
        results2[another[i]] = 0

    else:
        results2[another[i]] += 1
    f[i] = sorted(results[another[i]].items(), key=lambda x: x[1])[results2[another[i]]][0]
    latter = str(results2[another[i]]+1)

#[results2[another[i]]]
    if len(latter) < 6:
        latter = "0" *(6 - len(latter))+latter
    cnt.append((former + latter))
for i in f.values():
    print(cnt[i])

Submission status: Wrong Answer

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

for i in range(len(lis)):
    lis[i].append(i)

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

city = 0
cnt = 1
for i in range(len(lis)):
    if lis[i][0] is not city:
        city = lis[i][0]
        cnt = 1
    num = str(lis[i][0]).zfill(6) + str(cnt).zfill(6)
    lis[i].append(num)
    cnt += 1
    
lis.sort(key=lambda x:x[2])

for i in range(len(lis)):
    print(lis[i][3])

Submission status: Wrong Answer

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

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)

Submission status: Wrong Answer

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

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

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

for i in range(0, M):
    num = check[P[i]].index(Y[i])+1
    print(((6-len(str(num)))*'0')+str(P[i])+((6-len(str(P[i])))*'0')+str(num))

Submission status: Wrong Answer

Solution code:

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

# Input P, Y(m times)
p = list()
y = list()
i = list()
for idx in range(m):
    wkp, wky = map(int, input().split())
    p.append(wkp)
    y.append(wky)
    i.append(idx)

# Sort-Y
for idx_1 in range(0, m - 1, 1):
    min_y = y[idx_1]
    min_idx = -1
    for idx_2 in range(1, m, 1):
        if min_y > y[idx_2]:
            min_y = y[idx_2]
            min_idx = idx_2
    if min_idx > -1:
        swkp = p[idx_1]
        swky = y[idx_1]
        swki = i[idx_1]
        p[idx_1] = p[min_idx]
        y[idx_1] = y[min_idx]
        i[idx_1] = i[min_idx]
        p[min_idx] = swkp
        y[min_idx] = swky
        i[min_idx] = swki

# Sort-P
for idx_1 in range(0, m - 1, 1):
    min_p = p[idx_1]
    min_idx = -1
    for idx_2 in range(1, m, 1):
        if min_p > p[idx_2]:
            min_p = p[idx_2]
            min_idx = idx_2
    if min_idx > -1:
        swkp = p[idx_1]
        swky = y[idx_1]
        swki = i[idx_1]
        p[idx_1] = p[min_idx]
        y[idx_1] = y[min_idx]
        i[idx_1] = i[min_idx]
        p[min_idx] = swkp
        y[min_idx] = swky
        i[min_idx] = swki

# x Numbering
idno = list()
wkpref = -1

for idx_1 in range(m):
    if wkpref != p[idx_1]:
        cnt = 0
    wkpref = p[idx_1]
    cnt = cnt + 1
    
    # Form Identification number

    mkno = ""
    if p[idx_1] >= 100000:
        mkno = str(p[idx_1])
    elif p[idx_1] >= 10000:
        mkno = str("0" + str(p[idx_1]))
    elif p[idx_1] >= 1000:
        mkno = str("00" + str(p[idx_1]))
    elif p[idx_1] >= 100:
        mkno = str("000" + str(p[idx_1]))
    elif p[idx_1] >= 10:
        mkno = str("0000" + str(p[idx_1]))
    else:
        mkno = str("00000" + str(p[idx_1]))

    if cnt >= 100000:
        mkno = mkno + str(cnt)
    elif cnt >= 10000:
        mkno = mkno + str("0" + str(cnt))
    elif cnt >= 1000:
        mkno = mkno + str("00" + str(cnt))
    elif cnt >= 100:
        mkno = mkno + str("000" + str(cnt))
    elif cnt >= 10:
        mkno = mkno + str("0000" + str(cnt))
    else:
        mkno = mkno + str("00000" + str(cnt))
    idno.append(mkno)

# Sort i
for idx_1 in range(0, m - 1, 1):
    min_i = i[idx_1]
    min_idx = -1
    for idx_2 in range(1, m, 1):
        if min_i > i[idx_2]:
            min_i = i[idx_2]
            min_idx = idx_2
    if min_idx > -1:
        swkp = p[idx_1]
        swky = y[idx_1]
        swki = i[idx_1]
        swkno = idno[idx_1]
        p[idx_1] = p[min_idx]
        y[idx_1] = y[min_idx]
        i[idx_1] = i[min_idx]
        idno[idx_1] = idno[min_idx]
        p[min_idx] = swkp
        y[min_idx] = swky
        i[min_idx] = swki
        idno[min_idx] = swkno
# Output
for idx_1 in range(m):
    print(idno[idx_1])

Submission status: Wrong Answer

Solution code:
import copy

nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [[] for i in range(n)]
for i in range(m):
  c = input().split(' ')
  N[int(c[0])-1].append(int(c[1]))
  
N2 = copy.copy(N)
for i in range(n):
  Nd = []
  Nd.append(sorted(N[i]))
  if len(N[i]) != 0:
    for j in range(len(Nd[0])):
      N2[i][N[i].index(Nd[0][j])] = j


for i in range(n):
  if len(N[i]) != 0:
    for j in range(len(N2[i])):
      s = "0" * (6 - int(len(str(i)))) + str(i + 1)
      s += "0" * (6 - int(len(str(N2[i][j] + 1)))) + str(N2[i][j] + 1)
      print(s)

Submission status: Wrong Answer

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

cities = {}
for i in range(m):
    (i, j) = map(int, input().split())
    if not i in cities:
        cities[i] = []
    cities[i].append(j)
print(cities)
codes = []
for k, v in cities.items():
    v.sort()
    for i, j in enumerate(v):
        codes.append("{0:06d}".format(k) + "{0:06d}".format(i + 1))
for code in codes:
    print(code)

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int, input().split())
a = []
for i in range(m):
  pk,yk = map(int,input().split())
  b = [pk,yk,i]
  a.append(b)
a.sort(key=lambda x:(x[0],x[1]))
b = a[0][0]
c = 0
for i in range(len(a)):
  if a[i][0] != b:
    c = 1
  else:
    c += 1
  a[i].append(c)
a.sort(key=lambda x:x[2])
for i in range(len(a)):
  a[i].append(math.floor(math.log10(a[i][0])+1.0))
  a[i].append(math.floor(math.log10(a[i][3])+1.0))
  print(str("0"*(6-a[i][4]))+str(a[i][0])+str("0"*(6-a[i][5]))+str(a[i][3]))

Submission status: Wrong Answer

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

Indexs = []
Syuturyoku = []


for j in range(N):
	P.append([0])


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

	P[p-1].append(y)
	Indexs.append(y)
	Syuturyoku.append(("0","0"))

for i in range(len(P)):
	P[i].sort()
	P[i] = list(map(str,P[i]))


for i in range(len(P)):
	if(len(P[i])>1):
		zeros = ''
		zeros_2 = ''
		for j in range(len(P[i])-1):
			atai = P[i][j+1]
			si = i+1
			si = str(si)
			x = j+1
			x = str(x)
			bangou = list(map(str,si))
			bangou_len = int(len(bangou))
			bangou_ushiro = list(map(str,x))
			bangou_ushiro_len = int(len(bangou_ushiro))
			if(len(bangou)<6):
				for zero in range(6-bangou_len):
					zeros += '0'
			if(len(bangou_ushiro)<6):
				for zero in range(6-bangou_ushiro_len):
					zeros_2 += '0'

			mojiretsu = zeros+si
			mojiretsu2 = zeros_2+x

			a = Indexs.index(int(atai))
			Syuturyoku[a] = (mojiretsu,mojiretsu2)
for i in range(M):
	print(Syuturyoku[i][0]+Syuturyoku[i][1])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(" "))
cityList = []
preList = [0] * N

class City:
    def __init__(self, id, pre, year):
        self.id = id
        self.pre = pre
        self.year = year
        self.number = 0

for i in range(M):
    P, Y = map(int, input().split(" "))
    city = City(i+1, P, Y)
    cityList.append(city)

cityList.sort(key=lambda x:x.year)
cityList.sort(key=lambda x:x.pre)

num = 1
count = 1
for city in cityList:
    if(city.pre != num):
        num += 1
        count = 1
    city.number = str(city.pre).zfill(6) + str(count).zfill(6)
    count += 1

cityList.sort(key=lambda x:x.id)
for city in cityList:
    print(city.number)

Submission status: Wrong Answer

Solution code:
import copy

import copy

nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [[] for i in range(n)]
for i in range(m):
  c = input().split(' ')
  N[int(c[0])-1].append(int(c[1]))
  
N2 = copy.copy(N)
print(N2)
for i in range(n):
  Nd = []
  Nd.append(sorted(N[i]))
  if len(N[i]) != 0:
    for j in range(len(Nd[0])):
      N2[i][N[i].index(Nd[0][j])] = j


for i in range(n):
  if len(N[i]) != 0:
    for j in range(len(N2[i])):
      s = "0" * (6 - int(len(str(i)))) + str(i + 1)
      s += "0" * (6 - int(len(str(N2[i][j] + 1)))) + str(N2[i][j] + 1)
      print(s)

Submission status: Wrong Answer

Solution code:
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


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

ans = []

Ps = {}

for i in range(M):
	P,Y = list(map(int, input().split(' ')))

	if P in Ps:
		last = True
		jb = 1
		tp = 0
		for j  in range (len(Ps[P])):
			if Y < Ps[P][j][0]:
				Ps[P].insert(j, [Y, i])
				ans.append([P,jb])
				last = False
				tp = j
				break
				

		if last:
			Ps[P].append([Y, i])
			ans.append([P,len(Ps[P])])
		else:
			for k in range(tp+1,len(Ps[P])):
				ans[Ps[P][k][1]][1] += 1

	else:
		Ps[P] = [[Y,i]]
		ans.append([P,1])



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

Submission status: Wrong Answer

Solution code:

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

for i in range(1,N+1):
    for q in range(6):
        if 10**q<=i<10**(q+1):
            m=q
            pass
    w='0'*(5-m)+str(i)    
    dfi=[l for l in P if l==i]
    t=len(dfi)
    if t!=0:
        for s in range(t):
            for q in range(6):
                if 10**q<=i<10**(q+1):
                    n=q
                    pass
            e='0'*(5-n)+str(s+1)
            if s%10==9:
                e='0'*(4-q)+str(s+1)
            print(w+e)

Submission status: Wrong Answer

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


for i in range(m):
    c = 1
    for j in range(m):
        if py[i][0] == py[j][0] and py[i][1] > py[j][1]:
            c += 1
    a = py[i][0] * 10**6 + c
    if a < 10**7:
        print("00000",a)
    elif a < 10**8:
        print("0000",a)
    elif a < 10**9:
        print("000",a)
    elif a < 10**10:
        print("00",a)
    elif a < 10**11:
        print("0",a)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    data_sorted = sorted(data, key=itemgetter(0, 1))

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, code])
        p_prev = p

    sorted(codes, key=itemgetter(0))

    for i, code in codes:
        print(code)
        
main()

Submission status: Wrong Answer

Solution code:
import copy

import copy

nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [[] for i in range(n)]
for i in range(m):
  c = input().split(' ')
  N[int(c[0])-1].append(int(c[1]))
  
N2 = copy.copy(N)
for i in range(n):
  Nd = []
  Nd.append(sorted(N[i]))
  if len(N[i]) != 0:
    for j in range(len(Nd[0])):
      N2[i][N[i].index(Nd[0][j])] = j


for i in range(n):
  if len(N[i]) != 0:
    for j in range(len(N2[i])):
      s = "0" * (6 - int(len(str(i)))) + str(i)
      s += "0" * (6 - int(len(str(N2[i][j] + 1)))) + str(N2[i][j] + 1)
      print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int,input().split())
py = np.zeros(M*3).reshape(M,3)
for i in range(M):
    py[i][0] = i
    py[i][1],py[i][2] = map(int,input().split())
dtype=[('id',int),('p',int),('y',int)]
py = np.array(py,dtype=dtype)
np.sort(py,order=("p",'y'))
ans= ["1"]*M
h = 1
f = -1
for t in py:
    if f != int(t[1][0]):
        f = int(t[1][0])
        h = 1
    ans[t[0][0]] = "0"*(6-(f//10+1))+str(f)+"0"*(6-(h//10+1))+str(h)
    h += 1
for st in ans:
    print(st)

Submission status: Wrong Answer

Solution code:

from scipy.stats import rankdata
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append([y,p_count[p-1]])
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(rankdata(np.array(P_Y[i])))

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]]))
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
city = []
count = 1
for i in range(M):
    p,y = map(int,input().split())
    city.append([p,y])
city_sorted = sorted(city)
for i in range(M):
    if city_sorted[i][0] == city_sorted[i-1][0] and i != 0:
        count += 1
    else:
        count = 1
    city_sorted[i][1] = count
for i in range(M):
    number_f = "0"*(6-len(str(city[i][0]))) + str(city[i][0])
    number_b = "0"*(6-len(str(city[i][0]))) + str(city[i][1])
    print(number_f + number_b)

Submission status: Wrong Answer

Solution code:
import copy

import copy

nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])

N = [[] for i in range(n)]
for i in range(m):
  c = input().split(' ')
  N[int(c[0])-1].append(int(c[1]))
  
N2 = copy.copy(N)
print(N2)
for i in range(n):
  Nd = []
  Nd.append(sorted(N[i]))
  if len(N[i]) != 0:
    for j in range(len(Nd[0])):
      N2[i][N[i].index(Nd[0][j])] = j


for i in range(n):
  if len(N[i]) != 0:
    for j in range(len(N2[i])):
      s = "0" * (6 - int(len(str(i)))) + str(i)
      s += "0" * (6 - int(len(str(N2[i][j] + 1)))) + str(N2[i][j] + 1)
      print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np


N,M=map(int,input().split())
P=[]
Y=[]
for i in range(M):
    s,t=map(int,input().split())
    P.append(s)
    Y.append(t)
    
u=np.array([P])

for i in range(1,N+1):
    for q in range(6):
        if 10**q<=i<10**(q+1):
            m=q
            pass
    w='0'*(5-m)+str(i)    
    dfi=u[u==i]
    t=len(dfi)
    if t!=0:
        for s in range(t):
            for q in range(6):
                if 10**q<=i<10**(q+1):
                    n=q
                    pass
            e='0'*(5-n)+str(s+1)
            if s%10==9:
                e='0'*(4-q)+str(s+1)
            print(w+e)

Submission status: Wrong Answer

Solution code:
from scipy.stats import rankdata
N,M = list(map(int,input().split()))

PY = []
P_Y = [[] for i in range(N)]

p_count = [0 for i in range(N)]

for i in range(M):
    p,y = list(map(int,input().split()))
    P_Y[p-1].append([y,p_count[p-1]])
    p_count[p-1]+=1
    PY.append([p,y])
    
import numpy as np

P_Y_arg = []
for i in range(N):
    P_Y_arg.append(rankdata(np.array(P_Y[i])))

    
p_count = [0 for i in range(N)]

for i in range(M):
    ps = str(1000000+PY[i][0])
    ys = str(1000000+P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]] + 1)
    p_count[PY[i][0]-1]+=1
    print(ps[1:]+ys[1:])

Submission status: Wrong Answer

Solution code:
def con(var):
    var=str(var)
    while(len(var)<6):
        var="0"+var
    return var



def run():
    N,M=input().split()
    N=int(N)
    M=int(M)
    P=[-1]*M
    Y=[-1]*M
    arr=[]
    for i in range(M):
        P[i],Y[i]=input().split()
        P[i]=int(P[i])-1
        Y[i]=int(Y[i])
        arr.append([P[i],Y[i],i])
    arr=sorted(arr,key=lambda x:x[1])
    print(arr)
    ans=[0]*M
    cnt=[0]*N
    for i in range(M):
        cnt[arr[i][0]]=cnt[arr[i][0]]+1
        ans[arr[i][2]]=con(arr[i][0]+1)+con(cnt[arr[i][0]])
    for i in range(M):
        print(ans[i])
run()

Submission status: Wrong Answer

Solution code:
import copy
n, m = list(map(int, input().split()))
city_list = [[] for i in range(n)]
numbers = []
 
for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list[pm-1].append(ym)
city_list_copied = copy.deepcopy(city_list)
 
for i in range(n):
    city_list_copied[i].sort()
    for j in range(len(city_list[i])):
        cindex = city_list_copied[i].index(city_list[i][j])
        print("{:0=6}{:0=6}".format(i+1, cindex+1))

Submission status: Wrong Answer

Solution code:
import copy

read_line = input().split()
N = int(read_line[0])
M = int(read_line[1])

pref_city_list = []

for i in range(M) :
	in_str_list = input().split()
	in_str = in_str_list[0].zfill(6) + " " + in_str_list[1].zfill(6)
	pref_city_list.append(in_str)

list = copy.deepcopy(pref_city_list)
list.sort()

city_pref_id_dic = {}


prev_pref_id = list[0].split()[0]
city_count = 0

for i in range(len(list)) :
	factors = list[i].split()
	pref_id = factors[0]
	if (prev_pref_id != pref_id) :
		prev_pref_id = pref_id
		city_count = 0
	
	city_count = city_count + 1
	city_pref_id_dic[list[i]] = str(pref_id) + str(city_count).zfill(6)


for i in range(len(pref_city_list)) :
	print(city_pref_id_dic[pref_city_list[i]])

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
xs = [0]*m
pre = [0]*m
for x in range(m):
    xs[x] = list(list(map(int,input().split())) + [x] + [x])
xs.sort()

for p in range(1,n+1):
    cnt = 1
    flag = 0
    for x in xs:
        if x[0] == p:
            x[3] = cnt
            cnt += 1
        else:
            flag = 1
        if flag:
            break


for x in sorted(xs, key=lambda x:x[2]):
    print('{0:06d}'.format(x[0]) + '{0:06d}'.format(x[3]))

Submission status: Wrong Answer

Solution code:
import numpy as np
(N, M) = map(int,input().split())
P = np.empty(M,dtype=np.int64)
Y = np.empty(M,dtype=np.int64)
for i in range(M):
    (P[i], Y[i]) = map(int,input().split())

x = np.zeros(M,dtype=np.int64)
for i in range(M):
    if x[i] > 0:
        continue
    
    p = P[i]
    cities = np.where(P[i:]==p)[0] + i
    order = Y[cities].argsort() + 1
    for (j,c) in enumerate(cities):
        x[c] = order[j]

for i in range(M):
    print('{:0=6}'.format(P[i])+'{:0=6}'.format(x[i]))

Submission status: Wrong Answer

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

for i in range(len(lis)):
    lis[i].append(i)

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

for i in range(len(lis)):
    num = str(lis[i][0]).zfill(6) + str(i+1).zfill(6)
    lis[i].append(num)
    
lis.sort(key=lambda x:x[2])

for i in range(len(lis)):
    print(lis[i][3])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
pli = [[] for x in range(n)]
ansP = ["0" * (6 - len(str(x)))  + str(x) for x in range(1, n + 1)]
py = []
for i in range(m):
    p, y = map(int, input().split())
    py.append([p,y])
    pli[p-1].append(y)

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

for i in range(m):
    print(ansP[py[i][0]-1] + "0" * (6 - len(str(pli[py[i][0]-1].index(py[i][1])))) + str(pli[py[i][0]-1].index(py[i][1]) + 1))

Submission status: Wrong Answer

Solution code:
# - coding : utf-8 -*-
    
if __name__ == '__main__':
    n, m = map(int, raw_input().split())
    ps = []
    ys = []
    for i in range(0, m):
        p, y = map(int, raw_input().split())
        ps.append(p)
        ys.append(y)     
    for j, p in enumerate(ps):
        sort_ys = [ys[i] for i, x in enumerate(ps) if x == p]
        print str('%06d' % p) + str('%06d' % (int(sort_ys.index(ys[j]) + 1)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
p_dict = {}
p = [0 for i in range(M)]
y = [0 for i in range(M)]
i_in_p = [0 for i in range(M)]

for i in range(M):
    p[i], y[i] = map(int, input().split())
    if p[i] not in p_dict:
        i_in_p[i] = 0
        p_dict[p[i]] = [y[i]]
        continue
    i_in_p[i] = len(p_dict[p[i]])
    p_dict[p[i]].append(y[i])
for key in p_dict.keys():
    p_dict[key] = list(np.array(range(1, len(p_dict[key])+1))[np.array(p_dict[key]).argsort()])
for i in range(M):
    print('{:06d}{:06d}'.format(p[i], p_dict[p[i]][i_in_p[i]]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int,input().split())
data=[]
for i in range(M):
    data.append(list(map(int,input().split(" "))))

arr = np.array(data)
c1=np.arange(0,M)
arr=np.insert(arr,2,c1,axis=1)
#arr_sort=arr[np.argsort(arr[:,0])]
arr_sort=arr[np.argsort(arr[:,1])]
arr_sort=arr_sort[np.argsort(arr_sort[:,0])]

j=1
i_prev=1
res=[]
k = 0
for i in arr_sort:
    if(int(i[0])!=i_prev):
        j=1
    #print("{:06}{:06}".format(i[0],j))
    test = "{:06}{:06}".format(i[0],j)
    arr_sort[k][1]= str(test)
    k+=1
    j+=1
    i_prev=i[0]

arr_sort=arr_sort[np.argsort(arr_sort[:,2])]
for i in arr_sort:
    print("{:012}".format(i[1]))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

num = [np.argsort(l) for l in ps]

for i in range(len(num)):
    for e in num[i]:
        res[i].append(('0'*(6-len(str(i))) + str(i+1) + '0'*(6-len(str(e+1))) + str(e+1)))

# import ipdb; ipdb.set_trace()

for p in pp:
    if len(res[p-1]) > 0:
        print(res[p-1].pop(0))

Submission status: Wrong Answer

Solution code:
import math
n,m = map(int, input().split())
a = []
for i in range(m):
  pk,yk = map(int,input().split())
  b = [pk,yk,i]
  a.append(b)
a.sort()
b = a[0][0]
c = 0
for i in range(len(a)):
  if a[i][0] != b:
    c = 1
  else:
    c += 1
  a[i].append(c)
a.sort(key=lambda x:x[2])
for i in range(len(a)):
  a[i].append(math.floor(math.log10(a[i][0])+1.0))
  a[i].append(math.floor(math.log10(a[i][3])+1.0))
  print(str("0"*(6-a[i][4]))+str(a[i][0])+str("0"*(6-a[i][5]))+str(a[i][3]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = [int(_) for _ in input().split()]
PN = [[] for _ in range(M)]
Y = [[] for _ in range(N)]
P = [0 for _ in range(N)]
for i in range(M):
    p, y = [int(_) - 1 for _ in input().split()]
    PN[i] = [p, P[p]]
    Y[p].append(y)
    P[p] += 1
Y_rank = [np.argsort(_) for _ in Y]
for i in range(M):
    print(str(PN[i][0] + 1).zfill(6) + str(Y_rank[PN[i][0]][PN[i][1]] + 1).zfill(6))

Submission status: Wrong Answer

Solution code:

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

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

x = [0]*N
x[:] = map(int, input().split())
"""


N, M = map(int, input().split())
P = [0]*M
Y = [0]*M
for m in range(M):
    P[m], Y[m] = map(int, input().split())
city_list = [[0, 0, 0, 0, 0]]*M
for m in range(M):
    city_list[m] = [P[m], Y[m], 0, 0, m]
city_list.sort()
i = 1
city_id = [0]*M
cnt = 1
for m in range(M):
    if city_list[m][0] == i:
        city_id[m] = cnt
        cnt += 1
    else:
        i += 1
        cnt = 1
        city_id[m] = cnt
        cnt += 1
    city_list[m][2] = city_id[m]
    city_list[m][3] = int(math.log10(city_list[m][0]) + 1)    
    
city_list.sort(key=itemgetter(4), reverse=False)
ID = ["000000000000"]*M
for m in range(M):
    tmpID = 10**6*city_list[m][0]+city_list[m][2]
    ID[m] = "0"*(6-city_list[m][3])  + str(tmpID)
    print(ID[m])

Submission status: Wrong Answer

Solution code:
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


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

ans = []

Ps = {}

for i in range(M):
	P,Y = list(map(int, input().split(' ')))

	if P in Ps:
		last = True
		jb = 1
		tp = 0
		for j  in range (len(Ps[P])):
			if Y < Ps[P][j][0]:
				Ps[P].insert(j, [Y, i])
				ans.append([P,jb])
				last = False
				tp = j
				continue
			else:
				jb += 1
				

		if last:
			Ps[P].append([Y, i])
			ans.append([P,jb])
		else:
			for k in range(tp+1,len(Ps[P])):
				ans[Ps[P][k][1]][1] += 1

	else:
		Ps[P] = [[Y,i]]
		ans.append([P,1])



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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = [int(x) for x in input().strip('\n').split(' ')]
lis = np.zeros((M,3)).astype('int32')
for i in range(M):
    lis[i,0:2] = [int(x) for x in input().strip('\n').split(' ')]
    lis[lis[:,0]==lis[i,0],2] = (lis[lis[:,0]==lis[i,0],1].argsort()+1)
for i in range(M):
    print('%06d%06d' % (lis[i,0],lis[i,2]))

Submission status: Wrong Answer

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

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

count = 1
ans = [[]]*m
for i in range(m):
    ans[i] = [l[i][0], str(l[i][1]).zfill(6) + str(count).zfill(6)]
    count = count + 1

    if i != m-1 and l[i+1][1] != l[i][1]:
        count = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np


N,M=map(int,input().split())
P=[]
Y=[]
for i in range(M):
    s,t=map(int,input().split())
    P.append(s)
    Y.append(t)
    
u=np.array([P])
d=np.array([P,Y])
df=d.T
df.sort(1)
for i in range(1,N+1):
    for q in range(6):
        if 10**q<=i<10**(q+1):
            m=q
            pass
    w='0'*(5-m)+str(i)    
    dfi=u[u==i]
    t=len(dfi)
    for s in range(t):
        for q in range(6):
            if 10**q<=i<10**(q+1):
                n=q
                pass
        e='0'*(5-n)+str(s+1)
        if s%10==9:
            e='0'*(4-q)+str(s+1)
        print(w+e)