Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
p,y = 0,0
my_dict = dict()
def genFrstSix(P):
	str_ = str(P)
	while(len(str(str_))<6):
		str_ = "0"+ str_
		# print(str_)
	return str_
P,Y,tup=[],[],[]
for i in range(M):
	p,y = map(int,input().split())
	tup.append((p,y))
	if p in my_dict.keys():
		my_dict[p].append(y)
	else:
		my_dict[p] = [y]
	
L = []
for key,values in sorted(my_dict.items(), key =lambda x: x[0]):
	# print(key,values)
	for each in values:
		L.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])
# print(L)
# print(tup)
for i in range(len(tup)):
	for j in range(len(L)):
		# print(tup[i],L[j][0])
		if tup[i] == L[j][0]:
			print(L[j][1])



N,M = map(int,input().split())
p,y = 0,0
my_dict = dict()
def genFrstSix(P):
	str_ = str(P)
	while(len(str(str_))<6):
		str_ = "0"+ str_
		# print(str_)
	return str_
P,Y,tup=[],[],[]
for i in range(M):
	p,y = map(int,input().split())
	P.append(p)
	Y.append(y)
	tup.append((p,y))

for i in range(len(P)):
	if P[i] in my_dict.keys():
		my_dict[P[i]].append(Y[i])
	else:
		my_dict[P[i]] = [Y[i]]
# print(my_dict)

# print(genFrstSix(12))
# print(my_dict)
L = []
for key,values in sorted(my_dict.items(), key =lambda x: x[0]):
	# print(key,values)
	for each in values:
		L.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])
# print(L)
# print(tup)
for i in range(len(tup)):
	for j in range(len(L)):
		# print(tup[i],L[j][0])
		if tup[i] == L[j][0]:
			print(L[j][1])



N,M = map(int,input().split())
p,y = 0,0
my_dict = dict()
def genFrstSix(P):
	str_ = str(P)
	while(len(str(str_))<6):
		str_ = "0"+ str_
		# print(str_)
	return str_
P,Y,tup=[],[],[]
for i in range(M):
	p,y = map(int,input().split())
	tup.append((p,y))
	if p in my_dict.keys():
		my_dict[p].append(y)
	else:
		my_dict[p] = [y]

print(tup)	
L = []

for key,values in my_dict.items():
	for each in values:
		L.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])
		
# for key,values in sorted(my_dict.items(), key =lambda x: x[0]):
# 	# print(key,values)
	# for each in values:
	# 	L.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])

for i in range(len(tup)):
	for j in range(len(L)):
		# print(tup[i],L[j][0])
		if tup[i] == L[j][0]:
			print(L[j][1])



N,M = map(int,input().split())
p,y = 0,0
my_dict = dict()
def genFrstSix(P):
	str_ = str(P)
	while(len(str(str_))<6):
		str_ = "0"+ str_
		# print(str_)
	return str_
tup,P,Y= [],[],[]
for i in range(M):
	p,y = map(int,input().split())
	tup.append((p,y))
	if p in my_dict.keys():
		my_dict[p].append(y)
	else:
		my_dict[p] = [y]


for key in my_dict.keys():
	sorted_y = sorted(my_dict[key])
	ys = {y:i+1 for i,y in enumerate(sorted_y)}
	# if key in L.keys():
	my_dict[key] = ys	
	# else:
		# L[key]
# print(my_dict)
for each in tup:
	# print(each)
	# for p,y in each:
	p = each[0]
	y = each[1]
	print('{:06}{:06}'.format(p,my_dict[p][y]))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted