problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03221
u545368057
2,000
1,048,576
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.
['import numpy as np\nN, M = map(int,input().split())\nPs = [[] for _ in range(N)]\nfor i in range(M):\n j, Y = map(int,input().split())\n Ps[j-1].append([i,Y])\nprint(Ps)\nrets = [""]*M\nfor i,P in enumerate(Ps):\n if len(P)==0:\n continue\n inds = np.array(P)[:,0]\n years = np.array(P)[:,1]\n sorts = np.argsort(years)\n for (j,y,s) in zip(inds,years,sorts):\n rets[j] = "{:06d}{:06d}".format(i+1,s+1)\nfor ret in rets:\n print(ret)', 'from collections import defaultdict\nfrom bisect import bisect_left\nN, M = map(int, input().split())\nA = []\nB = defaultdict(list)\n \nfor i in range(M):\n p, y = map(int, input().split())\n A.append([p, y])\n B[p].append(y)\n \nfor key in B.keys():\n B[key].sort()\n\nprint(A,B)\nfor a in A:\n print(a[0],a[1],B[a[0]],bisect_left(B[a[0]],a[1]))\nfor a in A:\n print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))', 'import numpy as np\nN, M = map(int,input().split())\nPs = [[] for _ in range(N)]\nfor i in range(M):\n j, Y = map(int,input().split())\n Ps[j-1].append([i,Y])\nrets = [""]*M\nfor i,P in enumerate(Ps):\n if len(P)==0:\n continue\n \n inds = np.array(P)[:,0]\n years = np.array(P)[:,1]\n sorts = np.argsort(years)\n \n \n for i,(ind,s) in enumerate(zip(inds,sorts)):\n a = np.where(sorts==i)[0][0]\n rets[ind] = "{:06d}{:06d}".format(i+1,a+1)\n\n\n\nfor ret in rets:\n print(ret)', 'from collections import defaultdict\nfrom bisect import bisect_left\nN, M = map(int, input().split())\nA = []\nB = defaultdict(list)\n \nfor i in range(M):\n p, y = map(int, input().split())\n A.append([p, y])\n B[p].append(y)\n \nfor key in B.keys():\n B[key].sort()\n\n\n# for a in A:\n\nfor a in A:\n print("%06d%06d" % (a[0], bisect_left(B[a[0]], a[1])+1))']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s258640118', 's419900397', 's829802930', 's082610222']
[51916.0, 155432.0, 46316.0, 38444.0]
[2109.0, 2105.0, 2110.0, 648.0]
[454, 419, 545, 425]
p03221
u546338822
2,000
1,048,576
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.
['def main():\n import bisect\n n,m = map(int,input().split())\n d = [[] for i in range(n)]\n ans = [0 for i in range(m)]\n for i in range(m):\n p,y = map(int,input().split())\n d[p-1].append((y,i))\n for i,d_ in enumerate(d):\n d_.sort()\n for c, d__ in enumerate(d_):\n ans[d__[1]-1] = str(i+1).zfill(6) + str(c+1).zfill(6)\n for i in range(m):\n print(ans[i])\n\nif __name__ == "__main__":\n main()\n', 'def main():\n import bisect\n n,m = map(int,input().split())\n ids = [0 for i in range(m)]\n his = [[] for i in range(n)]\n city = [[] for i in range(n)]\n for i in range(m):\n p,y = map(int,input().split())\n ids[i] = p\n b = bisect.bisect_right(city[p-1],y)\n city[p-1].insert(b,y)\n his[p-1].insert(b,len(his[p-1]))\n print(ids,city,his)\n c = [0 for i in range(n)]\n for i in range(m):\n nm = his[ids[i]-1][c[ids[i]-1]] + 1\n print(str(0) * (6 - len(str(ids[i])))+ str(ids[i])+str(0) * (6-len(str(nm))) + str(nm))\n c[ids[i]-1]+=1\n\nif __name__ == "__main__":\n main()\n', 'def main():\n import bisect\n n,m = map(int,input().split())\n d = [[] for i in range(n)]\n ans = [0 for i in range(m)]\n for i in range(m):\n p,y = map(int,input().split())\n d[p-1].append((y,i))\n for i,d_ in enumerate(d):\n d_.sort()\n for c, d__ in enumerate(d_):\n ans[d__[1]] = str(i+1).zfill(6) + str(c+1).zfill(6)\n for i in range(m):\n print(ans[i])\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s237819953', 's892574667', 's276384944']
[38788.0, 39640.0, 38808.0]
[409.0, 2210.0, 407.0]
[454, 640, 452]
p03221
u549383771
2,000
1,048,576
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.
['n,m = map(int,input().split())\n\ntmpsort = [[0]for i in range(n)]\np_list = []\ny_list = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n tmpsort[p-1].append(y)\n p_list.append(p)\n y_list.append(y)\n\nfor i in range(m):\n tmpsort[i].sort()\nfor i in range(len(p_list)):\n idx = tmpsort[p_list[i]-1].index(y_list[i])\n print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))', 'n,m = map(int,input().split())\n\ntmpsort = [[0]]*n\np_list = []\ny_list = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n tmpsort[p-1].append(y)\n p_list.append(p)\n y_list.append(y)\n\nfor i in range(n):\n tmpsort[i].sort()\nfor i in range(len(p_list)):\n idx = tmpsort[p_list[i]-1].index(y_list[i])\n print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))', 'n,m = map(int,input().split())\n\ntmp_list = [[0]for i in range(n)]\np_list = []\ny_list = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n tmp_list[p-1].append(y)\n p_list.append(p)\n y_list.append(y)\n\nimport copy\ntmpsort = copy.deepcopy(tmp_list)\nfor i in range(len(tmp_list)):\n sorted(tmpsort[i])\nfor i in range(len(p_list)):\n idx = tmpsort[p_list[i]-1].index(y_list[i])\n print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))', 'N,M = map(int, input().split()) \npiys = [[] for _ in range(N)] \nfor i in range(M): \n p, y = map(int, input().split()) \n piys[p-1].append((y,i)) \n\nans = [None]*M \nfor p,iys in enumerate(piys): \n iys.sort() \n for k,(y,i) in enumerate(iys): \n ans[i] = "%06d%06d" % (p+1,k+1) \n\nfor i in ans: \n print(i) ']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s029981818', 's557990803', 's910091018', 's400800125']
[25156.0, 13000.0, 48276.0, 35944.0]
[2105.0, 2104.0, 2106.0, 595.0]
[388, 373, 449, 333]
p03221
u552357043
2,000
1,048,576
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.
['N, M = map(int, input().split())\nfrom collections import defaultdict\nd = defaultdict(list)\nl = [[] for i in range(M)]\nfor i in range(M):\n P,Y = map(str, input().split())\n P = "0" * len(P) + P\n d[P].append(int(Y))\n l[i] = [P,int(Y)]\nfor i in range(M):\n tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)\n print(l[i][0] + "0" * (6-len(tmp)) + tmp)', 'N, M = map(int, input().split())\nfrom collections import defaultdict\nd = defaultdict(list)\nfor i in range(M):\n P,Y = map(int, input().split())\n d[P].append([Y,i])\nl = [0 for i in range(M)] \ncnt = 0 \nfor key in d:\n data = sorted(d[key])\n tmp = 0\n for i in range(len(data)):\n l[cnt] = [str(key).zfill(6) + str(tmp+1).zfill(6), data[i][1]]\n cnt += 1\n tmp += 1\nl.sort(key = lambda x: x[1])\nfor i in range(M):\n print(l[i][0])']
['Wrong Answer', 'Accepted']
['s233369026', 's461729417']
[45120.0, 58804.0]
[2105.0, 966.0]
[361, 461]
p03221
u557494880
2,000
1,048,576
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.
['N,M = map(int,input().split())\nA = [[] for i in range(N+1)]\nB = []\nd = {}\nfor i in range(M):\n p,y = map(int,input().split())\n B.append((p,y))\n A[p].append(y)\nfor i in range(N+1):\n A[i].sorted\n n = len(A[i])\n for j in range(n):\n d[A[i][j]] = j+1\nfor i in range(M):\n p,y = B[i]\n q = d[y]\n m = 6 - len(str(p))\n n = 6 - len(str(q))\n ans = "0"*m + str(p) + "0"*m + str(q)', 'N,M = map(int,input().split())\nA = [[] for i in range(N+1)]\nB = []\nd = {}\nfor i in range(M):\n p,y = map(int,input().split())\n B.append((p,y))\n A[p].append(y)\nfor i in range(N+1):\n A[i].sorted\n n = len(A[i])\n for j in range(n):\n d[A[i][j]] = j+1\nfor i in range(M):\n p,y = B[i]\n q = d[y]\n m = 6 - len(str(p))\n n = 6 - len(str(q))\n ans = "0"*m + str(p) + "0"*m + str(q)\n print(ans)', 'N,M = map(int,input().split())\nA = [[] for i in range(N+1)]\nB = []\nd = {}\nfor i in range(M):\n p,y = map(int,input().split())\n B.append((p,y))\n A[p].append(y)\nfor i in range(N+1):\n A[i].sort()\n n = len(A[i])\n for j in range(n):\n d[A[i][j]] = j+1\nfor i in range(M):\n p,y = B[i]\n q = d[y]\n m = 6 - len(str(p))\n n = 6 - len(str(q))\n ans = "0"*m + str(p) + "0"*n + str(q)\n print(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s701664696', 's937026145', 's774948792']
[28220.0, 28220.0, 37548.0]
[381.0, 391.0, 705.0]
[406, 421, 422]
p03221
u559103167
2,000
1,048,576
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.
['import collections\nimport bisect\nn,m = map(int, input().split())\np = [list(map(int,input().split())) for i in range(m)]\na = collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n print("%06d%06d"%(x,bisect.bisect(a[x],y))', 'n, m = map(int, input().split())\np = [list(map(int, input().split())) for _ in range(m)]\nr = [0]*n\nfor i in range(m):\n r[p[i][0]-1]+=1\n print(f"{p[i][0]:0>6}{r[p[i][0]-1]:0>6}")', 'import collections\nimport bisect\nn,m = map(int, input().split())\np = [list(map(int,input().split())) for i in range(m)]\na = collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n print("%06d%06d"%(x,bisect.bisect(a[x],y)))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s449539389', 's822836793', 's085963836']
[2940.0, 2940.0, 43324.0]
[17.0, 17.0, 701.0]
[246, 183, 247]
p03221
u569742427
2,000
1,048,576
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.
['import numpy\n\nN,M=map(int,input().split())\nP=[]\nY=[]\nfor _ in range(M):\n data=[int(_) for _ in input().split()]\n P.append(data[0])\n Y.append(data[1])\n\ny=[]\nfor x in range(1,N+1):\n for m in range(M):\n if P[m]==x:\n y.append(Y[m])\n\n ind=numpy.array(y)\n ind=ind.argsort()\n print(ind)\n for i,k in enumerate(y):\n Y[Y.index(k)]=ind[i]+1\n y=[]\n\nfor x in range(M):\n xx=str(P[x])\n yy=str(Y[x])\n print(xx.zfill(6)+yy.zfill(6))\n', 'N,M=map(int,input().split())\ncity=[]\nfor i in range(M):\n p,y=map(int,input().split())\n city.append([i,p,y])\n\ncity.sort(key = lambda t:t[2])\ncity.sort(key = lambda t:t[1])\n\nid=1\nold_city=0\nfor city_id in city:\n if city_id[1]!=old_city:\n id=1\n city_id[2]=id\n id+=1\n old_city=city_id[1]\n\ncity.sort(key = lambda t:t[0])\n\nfor x in city:\n ans=x[1]*1000000+x[2]\n print("{0:012d}".format(ans))\n']
['Wrong Answer', 'Accepted']
['s960967266', 's999905465']
[22024.0, 24492.0]
[2109.0, 738.0]
[477, 417]
p03221
u573970531
2,000
1,048,576
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.
['n,m=list(map(int,input().split()))\ncity=[]\nfor i in range(m):\n city.append(list(map(int,input().split())))\ncity.sort()\nans=[]\ncount=0\nprecity=city[0][0]\nfor i in city:\n if i[0]==precity:\n count+=1\n else:\n count=1\n ans.append(str(i[0]).zfill(6)+str(count).zfill(6))\nans.sort()\nfor i in ans:\n print(i)', 'n,m=list(map(int,input().split()))\ncity=[]\nfor i in range(m):\n city.append(list(map(int,input().split()))+[i])\ncity.sort()\nans=[]\ncount=0\nprecity=city[0][0]\nfor i in city:\n if i[0]==precity:\n count+=1\n else:\n precity=i[0]\n count=1\n ans.append([i[2],str(i[0]).zfill(6)+str(count).zfill(6)])\nans.sort()\nfor i in ans:\n print(i[1])']
['Wrong Answer', 'Accepted']
['s172098351', 's070998854']
[36496.0, 41416.0]
[659.0, 936.0]
[328, 363]
p03221
u575431498
2,000
1,048,576
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.
['from bisect import bisect_left\n\nN, M = map(int, input().split())\n\nP = []\nY = []\nPY = [[] for _ in range(N+1)]\n\nfor _ in range(M):\n p, y = map(int, input().split())\n P.append(p)\n Y.append(y)\n PY[p].append(y)\n\nfor i in range(M+1):\n PY[i].sort()\n\nfor i in range(M):\n x = bisect_left(PY[P[i]], Y[i]) + 1\n print("%06d%06d" % (P[i], x))', "N, M = map(int, input().split())\nP_Y = []\nfor i in range(M):\n p, y = map(int, input().split())\n P_Y.append([p, y, i])\n\nsorted_P_Y = sorted(P_Y)\nrank = 1\nprev_p = -1\nfor p, y, i in sorted_P_Y:\n if prev_p != p:\n rank = 1\n else:\n rank += 1\n P_Y[i].append(rank)\n prev_p = p\nfor p, _, _, rank in P_Y:\n print(str(p).rjust(6, '0') + str(rank).rjust(6, '0'))"]
['Runtime Error', 'Accepted']
['s821586459', 's250557503']
[24116.0, 31676.0]
[636.0, 708.0]
[351, 385]
p03221
u576357314
2,000
1,048,576
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.
["n,m=map(int,input().split())\nken=[0 for i in range(n)]\nfor i in range(m):\n p,y=map(int,input().split())\n ken[p-1]+=1\nken0=[]\nfor i in range(n):\n for j in range(ken[i]):\n mae=str(i+1)\n ato=str(j+1)\n while len(mae)<6:\n mae='0'+mae\n while len(ato)<6:\n ato='0'+ato\n ken0.append(mae+ato)\nfor i in ken0:\n print(i)", "n,m=map(int,input().split())\npy=[]\nken=[]\nnumber=[]\nfor i in range(m):\n py.append(list(map(int,input().split())))\nfor j in range(n):\n ken.append([])\n number.append([])\nfor k in py:\n ken[k[0]-1].append(k[1])\nfor l in ken:\n for q in range(len(l)):\n number[ken.index(l)-1].append(q+1)\nfor r in number:\n for s in range(len(r)):\n r[s]=str(r[s])\n while len(r[s])<6:\n r[s]='0'+r[s]\nnumber1=[t+1 for t in range(n)]\nfor u in range(n):\n number1[u]=str(number1[u])\n while len(number1[u])<6:\n number1[u]='0'+number1[u]\nfor v in range(n):\n for w in number[v]:\n print(number1[v]+w)", "n,m=map(int,input().split())\nken=[[] for i in range(n)]\nfor i in range(m):\n p,y=map(int,input().split())\n ken[p-1].append([i,y])\nfor i in range(n):\n ken[i].sort(key=lambda x:x[1])\nken0=[]\nfor i in range(n):\n for j in range(len(ken[i])):\n mae=str(i+1)\n ato=str(j+1)\n while len(mae)<6:\n mae='0'+mae\n while len(ato)<6:\n ato='0'+ato\n ken0.append([ken[i][j][0],mae+ato])\nken0.sort(key=lambda x:x[0])\nfor i in ken0:\n print(i[1])"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s314163722', 's980790211', 's701560357']
[12328.0, 44624.0, 48792.0]
[597.0, 2106.0, 1213.0]
[376, 640, 494]
p03221
u578850957
2,000
1,048,576
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.
["import sys\ninput = sys.stdin.readline\nimport bisect\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nfor i in range(1,N_ken+1):ken_year_map[i]=[]\n\nken_list = [0]*M_si\nyear_list = [0]*M_si\n\nfor si in range(M_si):\n ken_list[si],year_list[si] = map(int,input().split())\n ken_year_map[ken_list[si]] += [year_list[si]]\n \nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in zip(ken_list,year_list):\n print('{:06}{:06}'.format(ken,bisect.bisect_right(d[ken], year)))\n", 'import sys\ninput sys.stdin.readline\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nken_year_list = []\n\nfor si in range(1,M_si+1):\n ken,year = map(int,input().split())\n ken_year_list.append([ken,year])\n if ken in ken_year_map:\n ken_year_map[ken].append(year)\n else:\n ken_year_map[ken] = [year]\nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in ken_year_list:\n print((str(ken*1000000 + ken_year_map[ken].index(year)+1)).zfill(12))\n', 'import sys\n\ninput = sys.stdin.readline\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nken_list = []\nyear_list = []\n\nfor si in range(1,M_si+1):\n ken,year = map(int,input().split())\n ken_list.append(ken)\n year_list.append(year)\n if ken in ken_year_map:\n ken_year_map[ken].append(year)\n else:\n ken_year_map[ken] = [year]\nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in zip(ken,year):\n print((str(ken*1000000 + ken_year_map[ken].index(year)+1)).zfill(12))\n', 'import sys\ninput = sys.stdin.readline\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nken_list = []\nyear_list = []\n\nfor si in range(1,M_si+1):\n ken,year = map(int,input().split())\n ken_list.append(ken)\n year_list.append(year)\n ken_year_map[ken] += [year]\n \nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in zip(ken_list,year_list):\n print((str(ken*1000000 + ken_year_map[ken].index(year)+1)).zfill(12))\n', "import sys\ninput = sys.stdin.readline\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nfor i in range(1,N_ken+1):ken_year_map[i]=[]\n\nken_list = [0]*M_si\nyear_list = [0]*M_si\n\nfor si in range(M_si):\n ken_list[si],year_list[si] = map(int,input().split())\n ken_year_map[ken_list[si]] += [year_list[si]]\n \nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in zip(ken_list,year_list):\n print('{:06}{:06}'.format(ken,bisect.bisect_right(d[ken], year)))\n", "import sys\ninput = sys.stdin.readline\nimport bisect\n\nN_ken,M_si = map(int,input().split())\nken_year_map = {}\nfor i in range(1,N_ken+1):ken_year_map[i]=[]\n\nken_list = [0]*M_si\nyear_list = [0]*M_si\n\nfor si in range(M_si):\n ken_list[si],year_list[si] = map(int,input().split())\n ken_year_map[ken_list[si]] += [year_list[si]]\n \nfor i in ken_year_map:\n ken_year_map[i].sort()\n\nfor ken,year in zip(ken_list,year_list):\n print('{:06}{:06}'.format(ken,bisect.bisect_right(ken_year_map[ken], year)))\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s255242630', 's347362671', 's367119652', 's872305272', 's934041806', 's212089892']
[31208.0, 2940.0, 29028.0, 3064.0, 31208.0, 32616.0]
[263.0, 17.0, 244.0, 17.0, 284.0, 492.0]
[499, 485, 527, 451, 485, 510]
p03221
u580362735
2,000
1,048,576
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.
["import numpy as np\nN,M = map(int,input().split())\nP = []\nY = []\nindex = range(1,M+1)\nfor i in range(M):\n a,b= map(int,input().split())\n P.append(a)\n Y.append(b)\nfor i in range(1,N+1):\n a = [j for j, x in enumerate(P) if x == i]\n for p in range(len(a)+1,1,-1):\n print('{0:04d}'.format(i)+'{0:04d}'.format(p-1))", 'import numpy as np\nN,M = map(int,input().split())\nP = []\nY = []\nindex = range(1,M+1)\nfor i in range(M):\n a,b= map(int,input().split())\n P.append(a)\n Y.append(b)\nprint(P)\nprint(Y)\nfor i in range(1,N+1):\n a = [j for j, x in enumerate(P) if x == i]\n for p in range(1,len(a)+1):\n print({0:04d}.format(i){0:04d}".format(p))', "N,M = map(int,input().split())\ncity_list = sorted([[list(map(int,input().split())),i] for i in range(M)])\nID = city_list[0][0]\nnum = 0\nans = []\nprint(city_list)\nfor i in range(M):\n if ID != city_list[i][0][0]:\n ID = city_list[i][0][0]\n num = 0\n num += 1\n ans.append([city_list[i][1],'{0:06d}'.format(ID)+'{0:06d}'.format(num)])\nans = sorted(ans)\nfor i in range(len(ans)):\n print(ans[i][1])", "N,M = map(int,input().split())\ncity_list = sorted([[int(x) for x in input().split()] for i in range(M)])\nID = city_list[0][0]\nnum = 0\nfor i in range(M):\n if ID != city_list[i][0]:\n ID = city_list[i][0]\n num = 0\n num += 1\n print('{0:06d}'.format(ID)+'{0:06d}'.format(num))", "N,M = map(int,input().split())\ncity_list = sorted([[int(x) for x in input().split()] for i in range(M)])\nID = city_list[0][0]\nnum = 0\nfor i in range(M):\n if ID != city_list[i][0]:\n ID = city_list[i][0]\n num = 0\n num += 1\n print('{0:04d}'.format(ID)+'{0:04d}'.format(num))", "N,M = map(int,input().split())\ncity_list = sorted([[list(map(int,input().split())),i] for i in range(M)])\nID = city_list[0][0]\nnum = 0\nans = []\nfor i in range(M):\n if ID != city_list[i][0][0]:\n ID = city_list[i][0][0]\n num = 0\n num += 1\n ans.append([city_list[i][1],'{0:06d}'.format(ID)+'{0:06d}'.format(num)])\nans = sorted(ans)\nfor i in range(len(ans)):\n print(ans[i][1])"]
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s079938736', 's101075629', 's615479816', 's682775989', 's832348726', 's875142105']
[22096.0, 3064.0, 56524.0, 24264.0, 22432.0, 53684.0]
[2109.0, 17.0, 1461.0, 697.0, 679.0, 1416.0]
[310, 319, 399, 273, 273, 382]
p03221
u580697892
2,000
1,048,576
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.
['#coding: utf-8\nfrom copy import deepcopy\n\n\ndef main():\n N, M = map(int, input().split())\n p_dict = {}\n for i in range(M):\n p, y = map(int, input().split())\n if p not in p_dict.keys():\n p_dict[p] = [[y, p, i]]\n else:\n \n p_dict[p].append([y, p, i])\n ans = []\n for p in p_dict.keys():\n print(p)\n p_dict[p].sort()\n for i in range(len(p_dict[p])):\n \n p_dict[p][i].append(i+1)\n ans.append(p_dict[p][i])\n #print(p_dict[p_list[0][0]])\n print(p_dict)\n \n ans.sort(key=lambda x: x[2])\n print(ans)\n for y, p, oi, si in ans:\n print("{:06d}{:06d}".format(p, si))\nif __name__ == "__main__":\n main()', '# coding: utf-8\n\nN, M = map(int, input().split())\np_dict = {}\nfor i in range(M):\n\tp, y = map(int, input().split())\n\tif p not in p_dict.keys():\n\t\tp_dict[p] = [[y, p, i]]\n else:\n\t\t\n\t\tp_dict[p].append([y, p, i])\nans = []\nfor p in p_dict.keys():\n p_dict[p].sort()\n for i in range(len(p_dict[p])):\n \n p_dict[p][i].append(i+1)\n ans.append(p_dict[p][i])\n# ans = [y, p, input_index, sorted_index]\nans.sort(key=lambda x: x[2])\nfor y, p, oi, si in ans:\n print("{:06d}{:06d}".format(p, si))\n', '# coding: utf-8\n\nN, M = map(int, input().split())\np_dict = {}\nfor i in range(M):\n p, y = map(int, input().split())\n if p not in p_dict.keys():\n p_dict[p] = [[y, p, i]]\n else:\n \n p_dict[p].append([y, p, i])\nans = []\nfor p in p_dict.keys():\n p_dict[p].sort()\n for i in range(len(p_dict[p])):\n \n p_dict[p][i].append(i+1)\n ans.append(p_dict[p][i])\n# ans = [y, p, input_index, sorted_index]\nans.sort(key=lambda x: x[2])\nfor y, p, oi, si in ans:\n print("{:06d}{:06d}".format(p, si))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s416665449', 's832865813', 's203857006']
[61236.0, 2940.0, 47404.0]
[1013.0, 17.0, 806.0]
[856, 597, 621]
p03221
u581187895
2,000
1,048,576
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.
['import sys\ninput = sys.stdin.readline\n\nimport collections, bisect\n\nn, m = map(int, input().split())\np = [[int(j) for j in input().split()] for i in range(m)]\na = collections.defaultdict(list)\nfor x, y in sorted(p):\n a[x] += [y]\nfor x, y in sorted(p):\n z = bisect.bisect(a[x], y)\n print("%06d%06d"%(x,z))\n \n', 'from collections import defaultdict\nfrom bisect import bisect_right\n\ndic_PY = defaultdict(list)\nN, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\nfor p, y in sorted(PY):\n dic_PY[p] += [y]\n \nfor p, y in PY:\n z = bisect_right(dic_PY[p], y)\n print("%06d%06d"%(p,z))']
['Wrong Answer', 'Accepted']
['s748091163', 's803751605']
[41112.0, 43328.0]
[603.0, 721.0]
[310, 306]
p03221
u584174687
2,000
1,048,576
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.
['\n\nif __name__ == \'__main__\':\n ken_num, city_num = list(map(int, input().split()))\n data = [list(map(int, input().split())).append(i) for i in range(city_num)]\n\n \n # data = [[1,32,0], [2,63,1],[1,12,2]]\n\n data = sorted(data, key=lambda x: (x[0], x[1]))\n\n count = 1\n ken_num = 1\n ans_data = {}\n\n for i in range(city_num):\n number = data[i][2]\n if data[i][0] != ken_num:\n count = 1\n ken_num = data[i][0]\n chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)\n ans_data.update({number:chr})\n count += 1\n\n for i in range(city_num):\n print(ans_data[i])', '\nif __name__ == \'__main__\':\n ken_num, city_num = list(map(int, input().split()))\n data = []\n for i in range(city_num):\n element = list(map(int, input().split()))\n element.append(i)\n data.append(element)\n\n data = sorted(data, key=lambda x: (x[0], x[1]))\n\n count = 1\n ken_num = 1\n ans_data = {}\n\n for i in range(city_num):\n number = data[i][2]\n if data[i][0] != ken_num:\n count = 1\n ken_num = data[i][0]\n chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)\n ans_data.update({number:chr})\n count += 1\n\n for i in range(city_num):\n print(ans_data[i])']
['Runtime Error', 'Accepted']
['s201032986', 's245155366']
[4800.0, 46236.0]
[309.0, 866.0]
[670, 663]
p03221
u589432040
2,000
1,048,576
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.
['N, M = map(int, input().split())\nl = []\nfor i in range(M):\n \tl.append(list(map(int, input().split())))\n\ndef FillZero(num,f=6):\n s = ""\n s += (f - len(str(num))) * "0"\n s += str(num)\n return(s)\n\nfor i in range(M):\n l[i].append(i)\n\nl = sorted(l, key = lambda x:(x[0],x[1]))\n\nkey0 = l[0][0]\nkey1 = 0\nfor i in range(M):\n if key0 == l[i][0]:\n \tkey1 += 1\n l[i][1] = key1\n else:\n key1 = 1\n l[i][1] = key1\n key0 += 1\n\nl = sorted(l, key = lambda x:x[2])\n\nfor i in range(M):\n print(FillZero(l[i][0]) + FillZero(l[i][1]))', 'def FillZero(num,f=6):\n s = ""\n s += (f - len(str(num))) * "0"\n s += str(num)\n return(s)\n\nfor i in range(M):\n l[i].append(i)\n\nl = sorted(l, key = lambda x:(x[0],x[1]))\n\nkey0 = l[0][0]\nkey1 = 0\nfor i in range(M):\n if key0 == l[i][0]:\n key1 += 1\n l[i][1] = key1\n else:\n key1 = 1\n l[i][1] = key1\n key0 += 1\n\nl = sorted(l, key = lambda x:x[2])\n\nfor i in range(M):\n print(FillZero(l[i][0]) + FillZero(l[i][1]))', 'N, M = map(int, input().split())\nl = []\nfor i in range(M):\n \tl.append(list(map(int, input().split())))\n\ndef FillZero(num,f=6):\n s = ""\n s += (f - len(str(num))) * "0"\n s += str(num)\n return(s)\n\nfor i in range(M):\n l[i].append(i)\n\nl = sorted(l, key = lambda x:(x[0],x[1]))\n\nkey0 = l[0][0]\nkey1 = 0\nfor i in range(M):\n if key0 == l[i][0]:\n key1 += 1\n l[i][1] = key1\n else:\n key1 = 1\n l[i][1] = key1\n key0 = l[i][0]\n\nl = sorted(l, key = lambda x:x[2])\n\nfor i in range(M):\n print(FillZero(l[i][0]) + FillZero(l[i][1]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s675604342', 's745771668', 's636112148']
[3064.0, 3064.0, 39444.0]
[18.0, 18.0, 897.0]
[568, 464, 574]
p03221
u593019570
2,000
1,048,576
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.
["a,b = map(int,input().split())\n\nc = [[] for i in range(a)]\nfor _ in range(b):\n f,g = map(int,input().split())\n c[f - 1].append(g)\n\nd = c.copy()\n\n\nfor i in range(a):\n if c[i] != []:\n c[i].sort()\n\n#print(c)\nh = []\nx =''\ny = ''\nfor j in range(a): \n x = str(j + 1)\n while len(x) <= 5:\n x = '0' + x\n if c[j] != []:\n for k in range(len(c[j])):\n for l in range(len(c[j])):\n if c[j][k] == d[j][l]:\n y = str(k + 1)\n while len(y) <= 5:\n y = '0' + y\n print(x+y)\n", "from collections import deque\n\na,b = map(int,input().split())\n\nc = [[] for i in range(a)]\nd = [deque() for i in range(a)]\nz = []\nfor _ in range(b):\n f,g = map(int,input().split())\n c[f - 1].append(g)\n d[f - 1].append(0)\n for num in range(len(c[f-1])):\n if c[f - 1][num] >= g:\n d[f-1][num] += 1\n z.append([f,g])\n\nprint(c,d)\nx =''\ny = ''\nfor j in range(b): \n x = str(z[j][0])\n x = '0' * (6 - len(x)) + x\n y = str(d[z[j][0] - 1].popleft())\n y = '0' * (6 - len(y)) + y\n print(x + y)", "import bisect\na,b = map(int,input().split())\n\nc = [[] for i in range(a)]\nz = []\nfor _ in range(b):\n f,g = map(int,input().split())\n c[f - 1].append(g)\n z.append([f,g])\n\nfor i in range(a):\n if c[i] != []:\n c[i].sort()\n\nx =''\ny = ''\nfor j in range(b): \n x = str(z[j][0])\n x = '0' * (6 - len(x)) + x\n y = str(bisect.bisect(c[z[j][0] - 1], z[j][1]))\n y = '0' * (6 - len(y)) + y\n print(x + y)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s046521906', 's929031566', 's546702114']
[20144.0, 100452.0, 32776.0]
[2104.0, 2108.0, 734.0]
[611, 531, 434]
p03221
u593567568
2,000
1,048,576
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.
["import sys\nfrom collections import defaultdict\nsys.setrecursionlimit(10 ** 7)\n\n\n\n\nN, M = map(int, input().split())\nPY = [[int(x) for x in input().split()] for _ in range(M)]\n\nPREFECTURE = defaultdict(list)\nfor p, y in PY:\n PREFECTURE[p].append(y)\n\nprint(PREFECTURE)\n\nfor i in PREFECTURE.keys():\n ys = sorted(PREFECTURE[i])\n y_to_i = {y: i+1 for i, y in enumerate(ys)}\n PREFECTURE[i] = y_to_i\n\nfor p, y in PY:\n print('{:06}{:06}'.format(p, PREFECTURE[p][y]))\n", "import sys\nfrom collections import defaultdict\nsys.setrecursionlimit(10 ** 7)\n\n\n\n\nN, M = map(int, input().split())\nPY = [[int(x) for x in input().split()] for _ in range(M)]\n\nPREFECTURE = defaultdict(list)\nfor p, y in PY:\n PREFECTURE[p].append(y)\n\nfor i in PREFECTURE.keys():\n ys = sorted(PREFECTURE[i])\n y_to_i = {y: i+1 for i, y in enumerate(ys)}\n PREFECTURE[i] = y_to_i\n\nfor p, y in PY:\n print('{:06}{:06}'.format(p, PREFECTURE[p][y]))\n"]
['Wrong Answer', 'Accepted']
['s934972998', 's296516618']
[61500.0, 59580.0]
[838.0, 757.0]
[495, 476]
p03221
u594244257
2,000
1,048,576
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.
["from bisect import bisect_left\nimport heapq\n\ndef solve():\n N,M = map(int, input().split())\n cities_in_prefecture = [[] for _ in range(N)]\n city_ids = []\n for _ in range(M):\n P,Y = map(int, input().split())\n x = bisect_left(cities_in_prefecture[P-1], Y)\n heapq.heappush(cities_in_prefecture[P-1], Y)\n print('{0:06d}{1:06d}'.format(P, x+1), flush=True)\n \nsolve()", "from bisect import bisect_left\n\ndef solve():\n N,M = map(int, input().split())\n cities_in_prefecture = [[] for _ in range(N)]\n city_ids = []\n PYs = []\n for _ in range(M):\n P,Y = map(int, input().split())\n PYs.append((P,Y))\n cities_in_prefecture[P-1].append(Y)\n for p in range(N): cities_in_prefecture[p].sort()\n for P, Y in PYs:\n x = bisect_left(cities_in_prefecture[P-1], Y)\n \n print('{0:06d}{1:06d}'.format(P, x+1), flush=True)\n \nsolve()"]
['Wrong Answer', 'Accepted']
['s348507679', 's351159987']
[22020.0, 32760.0]
[572.0, 615.0]
[407, 545]
p03221
u595289165
2,000
1,048,576
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.
['n, m = map(int, input().split())\nname = []\ncity = []\nprefecture = [1] * n\nfor i in range(m):\n a = list(map(int, input().split())) + [i+1]\n city.append(a)\n name.append("{}{}".format("0" * (6 - len(str(a[0]))), a[0]))\ncity_1 = sorted(city, key=lambda x: x[0])\ncity_sorted = sorted(city, key=lambda x: x[1])\n\nx = 1\nfor i in range(m):\n p, y, num = city_sorted[i]\n x = prefecture[p-1]\n name[num-1] += "{}{}".format("0" * (6 - len(str(x))), x)\n x += 1\nfor i in name:\n print(i)\n', 'n, m = map(int, input().split())\nname = []\ncity = []\nprefecture = [1] * n\nfor i in range(m):\n a = list(map(int, input().split())) + [i+1]\n city.append(a)\n name.append("{}{}".format("0" * (6 - len(str(a[0]))), a[0]))\n\n\nfor i in range(m):\n p, y, num = city[i]\n x = prefecture[p-1]\n name[num-1] += "{}{}".format("0" * (6 - len(str(x))), x)\n prefecture[p-1] += 1\nfor i in name:\n print(i)\n', 'n, m = map(int, input().split())\nname = []\ncity = []\nprefecture = [1] * n\nfor i in range(m):\n a = list(map(int, input().split())) + [i+1]\n city.append(a)\n name.append("{}{}".format("0" * (6 - len(str(a[0]))), a[0]))\ncity_1 = sorted(city, key=lambda x: x[0])\ncity_sorted = sorted(city, key=lambda x: x[1])\n\nx = 1\nfor i in range(m):\n p, y, num = city_sorted[i]\n x = prefecture[p-1]\n name[num-1] += "{}{}".format("0" * (6 - len(str(x))), x)\n prefecture[p-1] += 1\nfor i in name:\n print(i)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s275567046', 's447744542', 's581356224']
[39244.0, 32568.0, 39208.0]
[909.0, 747.0, 942.0]
[495, 408, 509]
p03221
u595353654
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\n\nN,M = [int(x) for x in stdin.readline().rstrip().split()]\ncounter = 0\ncountry = 1\n\nID = []\n\nfor i in range(M):\n p,y = [int(x) for x in stdin.readline().rstrip().split()]\n ID.append([p,y,i,"no"])\nID.sort(key=itemgetter(0,1))\n\nfor i in range(M):\n if ID[i][0] != country:\n counter = 0\n country = ID[i][0]\n counter += 1\n ID_m = format(ID[i][0],"04") + format(counter,"04")\n ID[i][3] = ID_m\n \nID.sort(key=itemgetter(2))\n\nfor i in range(M):\n print(ID[i][3])', '# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\n\nN,M = [int(x) for x in stdin.readline().rstrip().split()]\ncounter = 0\ncountry = 1\n\nID = []\n\nfor i in range(M):\n p,y = [int(x) for x in stdin.readline().rstrip().split()]\n ID.append([p,y,i,"no"])\nID.sort(key=itemgetter(0,1))\n\nfor i in range(M):\n if ID[i][0] != country:\n counter = 0\n country = ID[i][0]\n counter += 1\n ID_m = format(ID[i][0],"06") + format(counter,"06")\n ID[i][3] = ID_m\n \nID.sort(key=itemgetter(2))\n\nfor i in range(M):\n print(ID[i][3])']
['Wrong Answer', 'Accepted']
['s096355378', 's335933357']
[32416.0, 32408.0]
[671.0, 636.0]
[564, 564]
p03221
u595375942
2,000
1,048,576
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.
["from collections import defaultdict\n\nn, m = map(int, input().split())\nPY = [tuple(map(int, input().split())) for _ in range(m)]\nypi = sorted((y, p) for i, (p, y) in enumerate(PY))\nd = defaultdict(lambda: 0)\n\nans = [None]*m\n\nfor y, p in ypi:\n d[p] += 1\n ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)\n\nprint(*ans, sep='\\n')", "from collections import defaultdict\n\nn, m = map(int, input().split())\nPY = [tuple(map(int, input().split())) for _ in range(m)]\nypi = sorted((y, p, i) for i, (p, y) in enumerate(PY))\nd = defaultdict(lambda: 0)\n\nans = [None]*m\n\nfor y, p, i in ypi:\n d[p] += 1\n ans[i] = str(p).zfill(6) + str(d[p]).zfill(6)\n\nprint(*ans, sep='\\n')"]
['Runtime Error', 'Accepted']
['s363474256', 's946314733']
[24872.0, 44088.0]
[439.0, 670.0]
[327, 333]
p03221
u597374218
2,000
1,048,576
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.
['import collections,bisect\nN,M=map(int,input().split())\nPY=[list(map(int,input().split())) for i in range(M)]\nx=collections.defaultdict(list)\nfor city,year in PY:\n x[city]+=[year]\nfor city,year in PY:\n num=bisect.bisect(x[city],year)\n print("%06d%06d"%(city,num))', 'n,m=map(int,input().split())\ncnt=[0]*(n+1)\na=[]\nfor i in range(m):\n p,y=map(int,input().split())\n a.append((y,p,i))\na.sort()\nb=[]\nfor y,p,i in a:\n cnt[p]+=1\n b.append((i,"{0:06}{0:06}".format(p,cnt[p])))\nb.sort()\nfor i,r in b:\n print(r)', 'n,m=map(int,input().split())\ncnt=[0]*(n+1)\na=[]\nfor i in range(m):\n p,y=map(int,input().split())\n a.append((y,p,i))\na.sort()\nprint(a)\nb=[]\nfor y,p,i in a:\n cnt[p]+=1\n b.append((i,"{0:06}{0:06}".format(p,cnt[p])))\nb.sort()\nprint(b)\nfor i,r in b:\n print(r)', 'N,M=map(int,input().split())\nPY=[list(map(int,input().split())) for i in range(M)]\nx=collections.defaultdict(list)\nfor city,year in PY:\n x[city]+=[year]\nfor city,year in PY:\n num=bisect.bisect(x[city],year)\n print("%06d%06d"%(city,num))', 'import collections,bisect\nN,M=map(int,input().split())\nPY=[list(map(int,input().split())) for i in range(M)]\nx=collections.defaultdict(list)\nfor city,year in sorted(PY):\n x[city]+=[year]\nfor city,year in PY:\n num=bisect.bisect(x[city],year)\n print("%06d%06d"%(city,num))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s008253326', 's050286926', 's119256508', 's121414767', 's127698658']
[42492.0, 37136.0, 47148.0, 27396.0, 43332.0]
[653.0, 701.0, 820.0, 339.0, 714.0]
[271, 251, 269, 245, 279]
p03221
u599547273
2,000
1,048,576
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.
['from itertools import groupby\n\nn, m = map(int, input().split(" "))\npy = [list(map(int, input().split(" "))) for _ in range(m)]\n\npy = [py_i + [i] for i, py_i in enumerate(py)]\npy_ = []\nfor key, group in groupby(py, lambda x: x[0]):\n\tfor i, city in enumerate(group):\n\t\tpy_.append(city + [i+1])\npy = sorted(py_, key=lambda x: x[3])\n\nfor py_i in py:\n\tprint(str(py_i[0]).zfill(6) + str(py_i[3]).zfill(6))', 'from itertools import groupby\n\nn, m = map(int, input().split(" "))\npy = [list(map(int, input().split(" "))) for _ in range(m)]\n\npy = [py_i + [i] for i, py_i in enumerate(py)]\npy_ = []\nfor key, group in groupby(sorted(py, key=lambda x: x[0]), lambda x: x[0]):\n\tfor i, city in enumerate(sorted(group, key=lambda x: x[1])):\n\t\tpy_.append(city + [i+1])\n\npy = sorted(py_, key=lambda x: x[2])\n\nfor py_i in py:\n\tprint(str(py_i[0]).zfill(6) + str(py_i[3]).zfill(6))']
['Wrong Answer', 'Accepted']
['s048051642', 's436494437']
[40784.0, 45644.0]
[632.0, 1004.0]
[399, 456]
p03221
u600402037
2,000
1,048,576
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.
["import bisect\nimport collections\n\nN, M = map(int, input().split())\nPM = [[int(j) for j in input().split()] for i in range(M)]\nA = collections.defaultdict(list)\nfor x, y in sorted(PM):\n A[x] += [y]\nfor x, y in PM:\n z = bisect.bisect(A[x], y)\n print('%06d%06d'%(x,y))", '# coding: utf-8\nimport sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN, M = lr()\ncur = [1] * (N+1) # 1-indexed\nPY = [lr() + [i] for i in range(M)]\nPY.sort(key=lambda x: x[1])\nanswer = [None] * M # 0-indexed\nfor p, y, i in PY:\n x = str(p).zfill(6) + str(cur[p]).zfill(6)\n answer[i] = x\n cur[p] += 1\n\nfor a in answer:\n print(a)\n']
['Wrong Answer', 'Accepted']
['s911969132', 's273059815']
[41024.0, 32540.0]
[699.0, 549.0]
[274, 408]
p03221
u603234915
2,000
1,048,576
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.
['import bisect\nN, M = map(int, input().split())\nP, Y = [], []\npref = [[] for _ in range(N+1)] # non-0-indexed\nfor m in range(M):\n p,y = map(int, input().split())\n P.append(p)\n Y.append(y)\nbisect.insort(pref[p], y)\n\n \nfor p,y in zip(P,Y):\n ans = "{:0>6}".format(p)\n i = bisect.bisect(pref[p], y)\n ans += "{:0>6}".format(i)\n print(ans)\n', 'import bisect\nN, M = map(int, input().split())\nP, Y = [], []\npref = [[] for _ in range(N+1)] # non-0-indexed\nfor m in range(M):\n p,y = map(int, input().split())\n P.append(p)\n Y.append(y)\nfor i in len(pref):\n\tpref[i].sort()\n \nfor p,y in zip(P,Y):\n ans = "{:0>6}".format(p)\n i = bisect.bisect(pref[p], y)\n ans += "{:0>6}".format(i)\n print(ans)\n', 'import bisect\nN, M = map(int, input().split())\nP, Y = [], []\npref = [[] for _ in range(N+1)] # non-0-indexed\nfor m in range(M):\n p,y = map(int, input().split())\n P.append(p)\n Y.append(y)\nfor p in pref:\n\tp = p.sort()\n \nfor p,y in zip(P,Y):\n ans = "{:0>6}".format(p)\n i = bisect.bisect(pref[p], y)\n ans += "{:0>6}".format(i)\n print(ans)\n', 'import bisect\nN, M = map(int, input().split())\nP, Y = [], []\npref = [[] for _ in range(N+1)] # non-0-indexed\nfor m in range(M):\n p,y = map(int, input().split())\n P.append(p)\n Y.append(y)\n pref[p].append(y)\nfor i, p in enumerate(pref):\n pref[i] = sorted(p)\n \nfor p,y in zip(P,Y):\n ans = "{:0>6}".format(p)\n i = bisect.bisect(pref[p], y)\n ans += "{:0>6}".format(i)\n print(ans)\n\n\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s296225147', 's705493089', 's949046996', 's315052983']
[19484.0, 18200.0, 19472.0, 24116.0]
[530.0, 325.0, 563.0, 689.0]
[357, 366, 359, 407]
p03221
u603681803
2,000
1,048,576
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.
['\nN, M = map(int, input().split(" "))\n\ncity = []\nPY = []\nfor i in range(M):\n ll = [i] + list(map(int, input().split(" ")))\n # print(ll)\n PY.append(ll)\n\nPY = sorted(PY, key=lambda x: x[2])\nprint(PY)\n\nken = [1]*N\nanswer = []\nfor i in range(M):\n ue6 = "{0:06d}".format(PY[i][1])\n sita6 = "{0:06d}".format(ken[PY[i][1]-1])\n ken[PY[i][1]-1] += 1\n answer.append([PY[i][0], ue6+sita6])\n\nanswer = sorted(answer, key=lambda x: x[0])\nfor i in range(M):\n print(answer[i][1])', '\nN, M = map(int, input().split(" "))\n\ncity = []\nPY = []\nfor i in range(M):\n ll = [i] + list(map(int, input().split(" ")))\n # print(ll)\n PY.append(ll)\n\nPY = sorted(PY, key=lambda x: x[2])\n\n\nken = [1]*N\nanswer = []\nfor i in range(M):\n ue6 = "{0:06d}".format(PY[i][1])\n sita6 = "{0:06d}".format(ken[PY[i][1]-1])\n ken[PY[i][1]-1] += 1\n answer.append([PY[i][0], ue6+sita6])\n\nanswer = sorted(answer, key=lambda x: x[0])\nfor i in range(M):\n print(answer[i][1])']
['Wrong Answer', 'Accepted']
['s173346627', 's396035698']
[47352.0, 43380.0]
[1027.0, 951.0]
[486, 488]
p03221
u603958124
2,000
1,048,576
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.
['from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf\nfrom itertools import accumulate,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heappop,heappush\nfrom copy import deepcopy\nfrom time import time\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn, m = MAP()\np = [[i]+LIST() for i in range(m)]\nq = [0]*(n+1)\n\np.sort(key=itemgetter(2))\nfor x in p:\n q[x[1]] += 1\n x.append(q[x[1]])\n\np.sort(key=itemgetter(0))\nfor x in p:\n print(str(x[1]).zfill(6), str(x[3]).zfill(6))', 'from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf\nfrom itertools import accumulate,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heappop,heappush\nfrom copy import deepcopy\nfrom time import time\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn, m = MAP()\np = [[i]+LIST() for i in range(m)]\nq = [0]*(n+1)\n\np.sort(key=itemgetter(2))\nfor x in p:\n q[x[1]] += 1\n x.append(q[x[1]])\n\np.sort(key=itemgetter(0))\nfor x in p:\n print(str(x[1]).zfill(6)+str(x[3]).zfill(6))']
['Wrong Answer', 'Accepted']
['s989305806', 's925929467']
[38408.0, 38384.0]
[422.0, 427.0]
[865, 864]
p03221
u604896914
2,000
1,048,576
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.
['import math\n\ndef gcd(a,b):\n """Compute the greatest common divisor of a and b"""\n while b > 0:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n """Compute the lowest common multiple of a and b"""\n return a * b / gcd(a, b)\n\n\nN,M = list(map(int, input().split(\' \')))\n\nans = []\n\nPs = {}\n\nfor i in range(M):\n\tP,Y = list(map(int, input().split(\' \')))\n\n\tif P in Ps:\n\t\tlast = True\n\t\tjb = 1\n\t\ttp = 0\n\t\tfor j in range (len(Ps[P])):\n\t\t\tif Y < Ps[P][j][0]:\n\t\t\t\tPs[P].insert(j, [Y, i])\n\t\t\t\tans.append([P,jb])\n\t\t\t\tlast = False\n\t\t\t\ttp = j\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tjb += 1\n\t\t\t\t\n\n\t\tif last:\n\t\t\tPs[P].append([Y, i])\n\t\t\tans.append([P,jb])\n\t\telse:\n\t\t\tfor k in range(tp+1,len(Ps[P])):\n\t\t\t\tans[Ps[P][k][1]][1] += 1\n\n\telse:\n\t\tPs[P] = [[Y,i]]\n\t\tans.append([P,1])\n\n\n# {1: [[12, 2], [32, 0]], 2: [[63, 1]]}\nprint(Ps)\n\nfor elem in ans:\n\tprint(str(elem[0]).zfill(6)+str(elem[1]).zfill(6))', 'import math\n\ndef gcd(a,b):\n """Compute the greatest common divisor of a and b"""\n while b > 0:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n """Compute the lowest common multiple of a and b"""\n return a * b / gcd(a, b)\n\n\nN,M = list(map(int, input().split(\' \')))\n\n# Y,P,i\nCities = []\n\nfor i in range(M):\n\tP, Y = list(map(int, input().split(\' \')))\n\tCities.append([Y,P,i])\n\nCities.sort()\nPsCount = {}\n\n\nans = []\n\nfor c in Cities:\n\tif c[1] in PsCount:\n\t\tPsCount[c[1]] += 1\n\t\tans.append([c[2], c[1], PsCount[c[1]]])\n\telse:\n\t\tPsCount[c[1]] = 1\n\t\tans.append([c[2], c[1], 1])\n\nans.sort()\n\n\nfor elem in ans:\n\tprint(str(elem[1]).zfill(6)+str(elem[2]).zfill(6))']
['Wrong Answer', 'Accepted']
['s938249302', 's932005640']
[137120.0, 41792.0]
[2112.0, 935.0]
[880, 684]
p03221
u606033239
2,000
1,048,576
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.
['n,m=map(int,input().split())\na=[list(map(int,input().split())) for _ in range(m)]\ns=sorted(a,key=lambda x:(x[0],x[1]))\nf=s[0][0]\nd=1\nfor i in range(m):\n if s[i][0]==f:\n s[i][1]==d\n d+=1\n else:\n f=s[i][0]\n d=1\n s[i][1]=d\n d+=1\n\nfor i in range(m):\n z=str(a[i][0])\n x=str(a[i][1])\n n="0"*(6-len(z)) + z + "0"*(6-len(x)) + x \n print(n)', 'import bisect\nn,m=(int(i) for i in input().split())\na=[[] for _ in range(n)]\ns=[]\n\nfor _ in range(m):\n x,c=(int(i) for i in input().split())\n a[x-1].append(c)\n s.append((x,c))\nprint(a)\nprint(s)\n[a[i].sort() for i in range(n)]\nprint(a)\nfor x,c in s:\n print("{:06}{:06}".format(x, bisect.bisect_left(a[x-1],c)+1))', 'n,m=map(int,input().split())\na=[list(map(int,input().split())) for _ in range(m)]\n\ns = sorted(a,key=lambda x:(x[0],x[1]))\nf=s[0][0]\nd=1\nfor i in range(m):\n if s[i][0] == f:\n s[i][1]=d\n d+=1\n else:\n f=s[i][0]\n d=1\n s[i][1]=d\n d+=1\nfor i in range(m):\n print("{:06}".format(a[i][0]) +"{:06}".format(a[i][1]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s088885974', 's572528206', 's896603502']
[36256.0, 37100.0, 36236.0]
[769.0, 812.0, 733.0]
[391, 323, 356]
p03221
u606090886
2,000
1,048,576
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.
['n,m = map(int,input().split())\na = []\nb = []\nfor i in range(n):\n P,Y = map(int,input().split())\n a.append(P)\n b.append(Y)\n\n\n\n\n\ncount = 0\nans = 0\ni = 0\nA = sorted(a)\nwhile True:\n if m-b[a.index(A[i])] > 0:\n m -= b[a.index(A[i])]\n ans += A[i] * b[a.index(A[i])]\n else:\n ans += A[i]* m\n break\n i+=1\nprint(ans)', 'n,m = map(int,input().split())\ns = []\nfor i in range(m):\n a =list(map(int,input().split()))\n a.append(i)\n s.append(a)\ns.sort()\nprint(s)\nans = [0 for i in range(m)]\nnum = 0\nans_ = ""\nfor i in range(m):\n if num != s[i][0]:\n num = s[i][0]\n count = 1\n ans_ = str(s[i][0])\n ans__ = str(count)\n for j in range(5):\n if len(ans_) < 6:\n ans_ = "0"+ans_\n if len(ans__) < 6:\n ans__ = "0" + ans__\n ans[s[i][2]] = ans_+ans__\n count += 1\nfor i in range(m):\n print(ans[i])', 'n,m = map(int,input().split())\ns = []\nfor i in range(m):\n a =list(map(int,input().split()))\n a.append(i)\n s.append(a)\ns.sort()\nans = [0 for i in range(m)]\nnum = 0\nans_ = ""\nfor i in range(m):\n if num != s[i][0]:\n num = s[i][0]\n count = 1\n ans_ = str(s[i][0])\n ans__ = str(count)\n for j in range(5):\n if len(ans_) < 6:\n ans_ = "0"+ans_\n if len(ans__) < 6:\n ans__ = "0" + ans__\n ans[s[i][2]] = ans_+ans__\n count += 1\nfor i in range(m):\n print(ans[i])']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s340706230', 's855394830', 's398839788']
[12188.0, 41816.0, 39416.0]
[339.0, 1019.0, 918.0]
[595, 537, 528]
p03221
u607865971
2,000
1,048,576
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.
['import sys\nimport collections\nimport itertools\nimport math\nimport re\nfrom collections import Counter\nfrom collections import deque\nimport bisect\n\n\nMOD = 10 ** 9 + 7\n\nN, M = [int(x) for x in input().split()]\n\n\nKenList = [[] for _ in range(N)]\n\n\nPYlist = [None] * M\nfor i in range(M):\n P, Y = [int(x) for x in input().split()]\n P = P - 1\n PYlist[i] = (P, Y)\n KenList[P].append((i, Y))\n\n\n\n \n\nfor i in range(M):\n ken = PYlist[i][0]\n idx = 0\n kl = KenList[ken]\n for j in range(len(kl)):\n if kl[j][0] == i:\n idx = j\n break\n print("{0:06d}{1:06d}".format(ken+1, idx+1))\n\n\nsys.exit(0)\n', 'import sys\nimport collections\nimport itertools\nimport math\nimport re\nfrom collections import Counter\nfrom collections import deque\n\nMOD = 10 ** 9 + 7\n\nN, M = [int(x) for x in input().split()]\n\nPYC = []\nfor i in range(M):\n p, y = [int(x) for x in input().split()]\n PYC.append((p, y, i))\n\nPYC = sorted(PYC)\n\ncity = {}\n\npCount = 1\npreP = -1\nfor p, y, c in PYC:\n if preP != p:\n pCount = 1\n city[c] = (p, pCount)\n pCount += 1\n preP = p\n\nfor i in range(M):\n print("{:06d}{:06d}".format(city[i][0], city[i][1]))\n\n\nsys.exit(0)\n']
['Wrong Answer', 'Accepted']
['s923215719', 's937516170']
[39708.0, 38652.0]
[2105.0, 737.0]
[709, 547]
p03221
u610473220
2,000
1,048,576
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.
['N, M = map(int, input().split())\nPList = [[] for _ in range(N+1)]\n\nfor i in range(M):\n P, Y = map(int, input().split())\n PList[P].append([i , Y])\n\n#print(PList)\n\nans = [0] * M\n\nfor P, l in enumerate(PList):\n if not l:\n continue\n l.sort()\n for j, (i, Y) in enumerate(l):\n ans[i] = "{:06d}{:06d}".format(P, j+1)\n\n#print(ans)\n\nfor i in range(M):\n print(ans[i])', 'N, M = map(int, input().split())\n\nPiYList = []\n\nfor i in range(M):\n P ,Y = map(int, input().split())\n PiYList.append([P, Y, i])\n\nPiYList = sorted(PiYList, key = lambda x: x[0])\n\ntmp = 1\nx = 1\nfor j in range(M):\n if PiYList[j][0] != tmp:\n tmp = PiYList[j][0]\n x = 1\n ans = PiYList[j][0] * 1000000 + x\n ans = str(ans)\n ans = ans.zfill(12)\n PiYList[j][1] = ans\n x += 1\n\nPiYList = sorted(PiYList, key = lambda x: x[2])\n\nfor i in range(M):\n print(PiYList[i][1])', 'N, M = map(int, input().split())\nPList = [[] for _ in range(N+1)]\n\nfor i in range(M):\n P, Y = map(int, input().split())\n PList[P].append([i , Y])\n\n#print(PList)\n\nans = [0] * M\n\nfor P, l in enumerate(PList):\n if not l:\n continue\n l.sort()\n for j, (i, Y) in enumerate(l):\n ans[i] = "{:06d}{:06d}".format(P, j+1)\n\n#print(ans)\n\nprint("\\n".join(ans))', 'N, M = map(int, input().split())\nPList = [[] for _ in range(N+1)]\n\nfor i in range(M):\n P, Y = map(int, input().split())\n PList[P].append([Y, i])\n\n#print(PList)\n\nans = [0] * M\n\nfor P, l in enumerate(PList):\n if not l:\n continue\n l.sort()\n for j, (Y, i) in enumerate(l):\n ans[i] = "{:06d}{:06d}".format(P, j+1)\n\n#print(ans)\n\nprint("\\n".join(ans))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s222987831', 's534422800', 's889388281', 's634068616']
[39112.0, 31744.0, 41416.0, 41392.0]
[683.0, 674.0, 715.0, 642.0]
[389, 497, 374, 373]
p03221
u617037231
2,000
1,048,576
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.
["N,M = map(int,input().split())\nCity = dict()\nfor i in range(N):\n City[i+1] = []\nfor i in range(M):\n Ken,Year = map(int,input().split())\n City[Ken].append(Year)\nfor i in range(N):\n City[i+1].sort()\nfor i in range(1,N+1):\n for el in City[i]:\n el = City[i].index(el)\ndef Zip_code(Ken,rank):\n Ken = str(Ken)\n rank = str(rank)\n Add = (6-len(Ken)) * '0'\n Ken = Add + Ken\n Add = (6-len(rank)) * '0'\n rank = Add + rank\n return Ken+rank\nfor i in range(1,N+1):\n if City[i] != []:\n for el in City[i]:\n print(Zip_code(i,City[i].index(el)+1))", "def mips():\n return map(int,input().split())\ndef rev(data):\n a = data[0]\n data[0] = data[1]\n data[1] = a\n return None\nN,M = mips()\ndata = dict()\nfor i in range(M):\n pref,year = mips()\n if pref not in data:\n data[pref] = [[year,i+1,pref]]\n else:\n data[pref].append([year,i+1,pref])\nans = []\nfor pref in data:\n data[pref].sort()\n for i in range(len(data[pref])):\n data[pref][i][0] = i+1\n rev(data[pref][i])\n ans.append(data[pref][i])\nans.sort()\nfor i in range(M):\n ken = str(ans[i][2])\n when = str(ans[i][1])\n ken,when = format(ken,'0>6'),format(when,'0>6')\n print(ken+when)"]
['Wrong Answer', 'Accepted']
['s024433657', 's005237042']
[27872.0, 39984.0]
[2105.0, 933.0]
[593, 647]
p03221
u619455726
2,000
1,048,576
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.
["# -*- coding: utf-8 -*-\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n lst.append(list(map(int, input().split())) + [i])\n i+=1\nlst.sort()\nj=1\n\ni=1\nfor k in lst:\n if i != k[0]:\n i==k[0]\n j=1\n k[1]=i*1000000+j\n else:\n j+=1\n k[1]=i*1000000+j\n\n\n#ans\nfor ans in sorted(ll, key=lambda x:x[2]):\n print('{0:012d}'.format(ans[1]))", "# -*- coding: utf-8 -*-\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n lst.append(list(map(int, input().split())) + [i])\n i+=1\nlst = sorted(lst)\nj=1\n\ni=1\nfor k in lst:\n if i != k[0]:\n i==k[0]\n j=1\n k[1]=i*1000000+j\n else:\n j+=1\n k[1]=i*1000000+j\n\n#ans\nfor ans in sorted(ll, key=lambda x:x[2]):\n print('{0:012d}'.format(ans[1]))", "# -*- coding: utf-8 -*-\n#import numpy as np\n\ndef func1(lst, value):\n return [i for i, x in enumerate(lst) if x == value]\n\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n l = list(map(int, input().split()))\n l.append(i)\n lst.append(l)\n i+=1\ni=1\nres=[]\nfor i in range(1,n+1):\n j=1\n for k in sort(lst):\n if i == k[0]:\n res.append([k[2],str(k[0]).rjust(6,'0') + str(j).rjust(6,'0')])\n j+=1\n#ans\nfor ans in sort(res):\n print(ans[1])\n", "# -*- coding: utf-8 -*-\n#import numpy as np\n\ndef func1(lst, value):\n return [i for i, x in enumerate(lst) if x == value]\n\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n l = list(map(int, input().split()))\n l.append(i)\n lst.append(l)\n i+=1\ni=1\nres=[]\nfor i in range(1,n+1):\n j=1\n for k in lst.sort():\n if i == k[0]:\n res.append([k[2],str(k[0]).rjust(6,'0') + str(j).rjust(6,'0')])\n j+=1\n#ans\nfor ans in res.sort():\n print(ans[1])\n", "# -*- coding: utf-8 -*-\n#import numpy as np\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n l = map(int, input().split())\n lst.append(list(l))\n i+=1\n\nsort_lst = sorted(lst)\ni=1\nres=[]\nfor i in range(1,n+1):\n j=1\n for k in sort_lst:\n if i == k[0]:\n res.append([str(k[0])+str(k[1]),str(res[0]).rjust(6,'0') + str(res[2]).rjust(6,'0')])\n j+=1\n\n#ans\nfor ans in lst:\n for res in sort_lst:\n if str(ans[0])+str(ans[1]) == res[0]:\n print(res[1])\n", "# -*- coding: utf-8 -*-\nn,m = map(int, input().split())\ni=0\nlst = []\nwhile i < m: \n lst.append(list(map(int, input().split())) + [i])\n i+=1\nlst = sorted(lst)\nj=0\ni=1\nfor k in lst:\n if i != k[0]:\n i=k[0]\n j=1\n k[1]=i*1000000+j\n else:\n j+=1\n k[1]=i*1000000+j\n\n#ans\nfor ans in sorted(lst, key=lambda x:x[2]):\n print('{0:012d}'.format(ans[1]))\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s082345939', 's096665645', 's208188562', 's850114497', 's956557579', 's204439552']
[25224.0, 24480.0, 30580.0, 31060.0, 28656.0, 29488.0]
[581.0, 642.0, 405.0, 546.0, 2105.0, 811.0]
[384, 390, 493, 495, 515, 390]
p03221
u620846115
2,000
1,048,576
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.
['import collections\nimport bisect\nn,m=map(int,input().split())\np = [list(map(int,input().splilt())) for i in range(m)]\na=collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', 'import collections\nimport bisect\nn,m = map(int,input().split())\np = [list(map(int,input().splilt())) for i in range(m)]\na = collections.deefaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z = bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', 'import collections\nimport bisect\nn,m=map(int,input().split())\np = [map(int,input().splilt()) for i in range(m)]\na=collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', 'import collections\nimport bisect\nn,m = map(int,input().split())\np = [list(map(int,input().splilt())) for i in range(m)]\na = collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z = bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', 'import collections\nimport bisect\nn,m=map(int,input().split())\np=[[int(j) for j in input().split()] for i in range(m)]\na=collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s005049747', 's233138010', 's267934399', 's467197538', 's672795964']
[9472.0, 9404.0, 9468.0, 9336.0, 42992.0]
[27.0, 28.0, 27.0, 27.0, 516.0]
[255, 256, 249, 255, 255]
p03221
u620868411
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\nn,m = map(int, input().split())\nd = {}\nfor i in range(1,m+1):\n p,y = map(int, input().split())\n if p not in d:\n d[p] = []\n d[p].append([y,i])\n\nfor k in d.keys():\n d[k] = sorted(d[k])\n\nret = []\nfor k in d.keys():\n for i in range(len(d[k])):\n idx = i+1\n ret.append("{:06x}{:06x}".format(k,idx))\n\nfor s in sorted(ret):\n print(s)\n', '# -*- coding: utf-8 -*-\n\nn,m = map(int, input().split())\nd = {}\npy = []\nfor i in range(1,m+1):\n p,y = map(int, input().split())\n py.append((p,y))\n if p not in d:\n d[p] = []\n d[p].append([y,i])\n\nret = {}\nfor k in d.keys():\n d[k] = sorted(d[k])\n ret[k] = {}\n for i in range(len(d[k])):\n ret[k][d[k][i][0]] = i+1\n\nfor p,y in py:\n print("{:06}{:06}".format(p,ret[p][y]))\n']
['Wrong Answer', 'Accepted']
['s847251222', 's424742340']
[48440.0, 83524.0]
[745.0, 1045.0]
[389, 405]
p03221
u623687794
2,000
1,048,576
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.
['n,m=map(int,input().split())\ncities=[[] for i in range(n)]\nfor i in range(1,m+1):\n p,y=map(int,input().split())\n cities[p-1].append(y)\n print(format(str(p),"0>6")+format(str(len(cities[p-1])),"0>6"))', 'n,m=map(int,input().split())\ncities=[[] for i in range(n)]\nfor i in range(1,m+1):\n p,y=map(int,input().split())\n cities[p-1].append(y)\n print(format(str(p),"0>6")+format(str(len(cities[p-1],"0>6"))))\n ', 'import sys\nn,m=map(int,input().split())\nif m==1:\n a,b=map(int,input().split())\n print(str(a).zfill(6)+str(m).zfill(6));sys.exit()\ncities=[None]*m\nfor i in range(m):\n p,y=map(int,input().split())\n cities[i]=[p,y,i]\ncities.sort(key=lambda x:x[1]);cities.sort(key=lambda x:x[0])\ni=0\nc=1\nwhile True:\n cities[i].append(c)\n c+=1\n if i!=m-1 and cities[i][0]!=cities[i+1][0]:c=1\n elif i==m-1:break\n i+=1\ncities.sort(key=lambda x:x[2])\nfor i in cities:\n print(str(i[0]).zfill(6)+str(i[3]).zfill(6))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s852488393', 's923995481', 's770156015']
[19120.0, 10288.0, 31004.0]
[1055.0, 35.0, 735.0]
[202, 205, 499]
p03221
u624617831
2,000
1,048,576
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.
["n = list(map(int, input().split()))\nN, M = n[0], n[1]\n\nimport numpy as np\n\ndef main():\n M_list = []\n y_array = np.array([[10000000000]*M]*N)\n for i in range(M):\n tmp = list(map(int, input().split()))\n M_list.append(tmp[0])\n y_array[tmp[0]-1,i] = tmp[1]\n\n num_array = np.zeros([N,M])\n ynum_array = np.ones([N,M])\n for k in range(N):\n #print(np.argsort(y_array[k]))\n num_array[k,:] = np.argsort(y_array[k])\n y_sorted = np.sort(y_array)\n tmp = 1\n for l in np.argsort(y_array[k]):\n if int(ynum_array[k][l]) == 10000000000:\n break\n ynum_array[k][l] = tmp\n tmp += 1\n\n for j in range(M):\n ac = (str(M_list[j]).zfill(5)) + (str(int(ynum_array[M_list[j]-1][j])).zfill(5))\n print(ac)\n \n #print(y_array)\n\nif __name__ == '__main__':\n main()\n\n\n", 'n, m = map(int, input().split())\n\ncity_list = []\nfor i in range(m):\n p, y = map(int, input().split())\n city_list.append([p, y, i])\n\ncity_list.sort(key=lambda x: (x[0], x[1]))\n\n#print(city_list)\n\ntmp_list = [0]*m\ntmp_num = 1\nfor num,j in enumerate(city_list):\n if num == 0:\n tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)\n j_tmp = j[0]\n tmp_num += 1\n else:\n if j[0] != j_tmp:\n j_tmp = j[0]\n tmp_num = 1\n tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)\n tmp_num += 1\n else:\n tmp_list[j[2]] = str(j[0]).zfill(6)+str(tmp_num).zfill(6)\n tmp_num += 1\n\nfor k in tmp_list:\n print(k)']
['Wrong Answer', 'Accepted']
['s103084690', 's500672823']
[50932.0, 31440.0]
[2109.0, 703.0]
[883, 711]
p03221
u625554679
2,000
1,048,576
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.
['import numpy as np\nN, M = [int(a) for a in input().split()]\nP = []\nY = []\n\nfor _ in range(M):\n p, y = [int(a) for a in input().split()]\n P.append(p)\n Y.append(y)\n\nindex = {}\nid = ["" for _ in range(len(P))]\n\nfor i in np.argsort(Y):\n index[P[i]] = index.get(P[i], 0)\n id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])\n index[P[i]] += 1\n\nfor i in id:\n print(i)', 'import numpy as np\nN, M = [int(a) for a in input().split()]\nP = []\nY = []\n\nfor _ in range(M):\n p, y = [int(a) for a in input().split()]\n P.append(p)\n Y.append(y)\n\nindex = {}\nid = ["" for _ in range(len(P))]\n\nfor i in np.argsort(Y):\n index[P[i]] = index.get(P[i], 0)\n id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])\n index[P[i]] += 1\n\nfor i in id:\n print(i)', 'import numpy as np\nN, M = [int(a) for a in input().split()]\nP = []\nY = []\n\nfor _ in range(M):\n p, y = [int(a) for a in input().split()]\n P.append(p)\n Y.append(y)\n\nindex = {}\nid = ["" for _ in range(len(P))]\n\nfor i in np.argsort(Y):\n index[P[i]] = index.get(P[i], 1)\n id[i] = "{0:06d}".format(P[i])+"{0:06d}".format(index[P[i]])\n index[P[i]] += 1\n\nfor i in id:\n print(i)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s422365040', 's818922833', 's331229452']
[36280.0, 40728.0, 36368.0]
[759.0, 1109.0, 774.0]
[391, 391, 392]
p03221
u625729943
2,000
1,048,576
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.
["N, M = map(int, input().split())\nPY = [[i,0] + list(map(int, input().split())) for i in range(M)]\n# [index, nth city, pref num, birth year]\n\nPY.sort(key=lambda x:(x[2],x[3]))\n\np = -1\nfor i,py in enumerate(PY):\n if p != py[3]:\n p = py[3]\n num = 1\n PY[i][1] = num\n else:\n num += 1\n PY[i][1] = num\n\nPY.sort(key=lambda x:x[0])\n\nfor py in PY:\n print('{:0=6}{:0=6}'.format(py[2], py[1]))\n", "#import numpy as np\nimport sys, math\nfrom itertools import permutations, combinations\nfrom collections import defaultdict, Counter, deque\nfrom math import factorial#, gcd\nfrom bisect import bisect_left \nsys.setrecursionlimit(10**7)\nenu = enumerate\nMOD = 10**9+7\ndef input(): return sys.stdin.readline()[:-1]\npl = lambda x: print(*x, sep='\\n')\n\nN, M = map(int, input().split())\n# PY = [list(map(int, input().split())) for _ in range(M)]\nPY = []\nfor i in range(M):\n P, Y = map(int, input().split())\n PY.append((i, P, Y))\n\nPYs = sorted(PY, key=lambda x:(x[1], x[2]))\n# print(PYs)\n\nd = defaultdict(int)\nress = []\nfor py in PYs:\n i, p, y = py\n ress.append((i, p, d[p]+1))\n d[p] += 1\n\nress.sort(key=lambda x: x[0])\nfor res in ress:\n i, p, o = res\n print(str(p).zfill(6)+str(o).zfill(6))\n"]
['Wrong Answer', 'Accepted']
['s003913431', 's326580258']
[37276.0, 43012.0]
[772.0, 659.0]
[400, 827]
p03221
u626337957
2,000
1,048,576
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.
["N, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append((P, Y, i))\nans = ['']*(M)\nprint(L)\nL.sort(key=lambda x:(x[0], x[1]))\nbefore = L[0][0]\nnum = 0\nfor i in range(M):\n if L[i][0] == before:\n num += 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n else:\n num = 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n before = L[i][0]\nfor city in ans:\n print(city)\n", "N, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append((P, Y, i))\nans = ['']*(M)\nL.sort(key=lambda x:(x[0], x[1]))\nbefore = L[0][0]\nnum = 1\nfor i in range(M):\n if L[i][0] == before:\n num += 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n else:\n num = 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n before = L[i][0]\nfor city in ans:\n print(city)\n \n \n \n\n", "N, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append((P, Y, i))\nans = ['']*(N)\n\nL.sort(key=lambda x:(x[0], x[1]))\nbefore = L[0][0]\nnum = 1\nfor i in range(M):\n if L[i][0] == before:\n num += 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n else:\n num = 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n before = L[i][0]\nfor city in ans:\n print(city)\n \n \n ", "N, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append((P, Y, i))\nans = ['']*(M)\nL.sort(key=lambda x:(x[0], x[1]))\nbefore = L[0][0]\nnum = 0\nfor i in range(M):\n if L[i][0] == before:\n num += 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n else:\n num = 1\n id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)\n ans[L[i][2]] = id\n before = L[i][0]\nfor city in ans:\n print(city)\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s537535356', 's874385220', 's998328232', 's496027796']
[33984.0, 29276.0, 29276.0, 29516.0]
[722.0, 660.0, 691.0, 665.0]
[485, 488, 487, 476]
p03221
u626881915
2,000
1,048,576
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.
['n,m=map(int, input().split())\np=[1]*(n+1)\nc=[]\nfor i in range(m):\n pi,x =map(int, input().split())\n c.append([i+1, pi, x, 0])\n #p[pi].append(x)\n\n\nx_order = sorted(c, key=lambda e: e[2])\nfor e in range(x_order):\n e[3] = p[pi]\n p[pi] += 1\n\ni_order = sorted(x_order)\nfor e in i_order:\n id=e[1]*1000000+e[3]\n print(str(id).zfill(12))\n', 'n,m=map(int, input().split())\np=[1]*(n+1)\nc=[]\nfor i in range(m):\n pi,x =map(int, input().split())\n c.append([i+1, pi, x, 0])\n #p[pi].append(x)\n\n\nx_order = sorted(c, key=lambda e: e[2])\nfor e in x_order:\n e[3] = p[pi]\n p[pi] += 1\n\ni_order = sorted(x_order)\nfor e in i_order:\n id=e[1]*1000000+e[3]\n print(str(id).zfill(12))\n', 'n,m=map(int, input().split())\np=[[] for i in range(n+1)]\nc=[]\nfor i in range(m):\n pi,x =map(int, input().split())\n c.append((pi,x))\n p[pi].append(x)\nfor i in range(n):\n p[i]=sorted(p[i])\nfor e in c:\n id=e[0]*1000000+p[e[0]].index(e[1])+1\n proud(str(id).zfill(12))', 'n,m=map(int, input().split())\np=[1]*(n+1)\nc=[]\nfor i in range(m):\n pi,x =map(int, input().split())\n c.append([i+1, pi, x, 0])\n #p[pi].append(x)\n\n\nx_order = sorted(c, key=lambda e: e[2])\nfor e in x_order:\n e[3] = p[e[1]]\n p[e[1]] += 1\n\ni_order = sorted(x_order)\n\nfor e in i_order:\n id=e[1]*1000000+e[3]\n print(str(id).zfill(12))\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s212677941', 's379939588', 's892130337', 's277524014']
[27600.0, 31540.0, 28224.0, 31540.0]
[432.0, 757.0, 438.0, 701.0]
[375, 368, 269, 373]
p03221
u628538573
2,000
1,048,576
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.
['n, m = map(int, input().split())\na = []\nfor i in range(m):\n\ta.append([int(n) for n in input().split()])\n\ta[i].append(i)\nprint(a)\nb = []\ncounter = 0\ncounter1 = 1\nfor i in range(m):\n\tc = ""\n\tif a[i][0] < 100000:\n\t\tgetlen = len(str(a[i][0]))\n\t\tc = "0" * (6 - getlen) + str(a[i][0])\n\telse:\n\t\tc = str(a[i][0])\n\tif i == 0:\n\t\tc += "000001"\n\t\tcounter = a[0][0]\n\telif a[i][0] == counter:\n\t\tgetlen = len(str(counter1 + 1))\n\t\tc += "0" * (6 - getlen) + str(counter1 + 1)\n\t\tcounter1 += 1\n\telse:\n\t\tcounter1 = 1\n\t\tc += "000001"\n\t\tcounter = a[i][0]\n\ta[i].append(c)\n\nfor i in range(m):\n\ta[i][2], a[i][0] = a[i][0], a[i][2]\na = sorted(a)\nfor i in range(m):\n\tprint(a[i][3])', 'n, m = map(int, input().split())\na = []\nfor i in range(m):\n\ta.append([int(n) for n in input().split()])\n\ta[i].append(i)\na = sorted(a)\nb = []\ncounter = 0\ncounter1 = 1\nfor i in range(m):\n\tc = ""\n\tif a[i][0] < 100000:\n\t\tgetlen = len(str(a[i][0]))\n\t\tc = "0" * (6 - getlen) + str(a[i][0])\n\telse:\n\t\tc = str(a[i][0])\n\tif i == 0:\n\t\tc += "000001"\n\t\tcounter = a[0][0]\n\telif a[i][0] == counter:\n\t\tgetlen = len(str(counter1 + 1))\n\t\tc += "0" * (6 - getlen) + str(counter1 + 1)\n\t\tcounter1 += 1\n\telse:\n\t\tcounter1 = 1\n\t\tc += "000001"\n\t\tcounter = a[i][0]\n\ta[i].append(c)\n\nfor i in range(m):\n\ta[i][2], a[i][0] = a[i][0], a[i][2]\na = sorted(a)\nfor i in range(m):\n\tprint(a[i][3])']
['Wrong Answer', 'Accepted']
['s436338169', 's715046074']
[34796.0, 32372.0]
[673.0, 950.0]
[654, 659]
p03221
u629350026
2,000
1,048,576
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.
['n,m=map(int,input().split())\ntemp=[0]*m\nfor i in range(0,m):\n p,y=map(int,input().split())\n temp[i]=[i,p,y]\ntemp.sort(key=lambda x: x[2]) \ntemp.sort(key=lambda x: x[1]) \nprint(temp)\nj=1\nn=1\nfor i in range(0,m):\n if temp[i][1]==n:\n tempn=str(n)\n tempj=str(j)\n temp[i][1]=tempn.zfill(6)\n temp[i][2]=tempj.zfill(6)\n j=j+1\n else:\n n=n+1\n j=1\n tempn=str(n)\n tempj=str(j)\n temp[i][1]=tempn.zfill(6)\n temp[i][2]=tempj.zfill(6)\n j=j+1\ntemp.sort(key=lambda x: x[0])\nfor i in range(0,m):\n print(temp[i][1]+temp[i][2])', 'n,m=map(int,input().split())\ntemp=[0]*m\ntempn=[]\nfor i in range(0,m):\n p,y=map(int,input().split())\n temp[i]=[i,p,y]\n tempn.append(p)\ntemp.sort(key=lambda x: x[2]) \ntemp.sort(key=lambda x: x[1]) \nj=1\ntempn=list(set(tempn))\ntempn.sort()\nk=0\nn=tempn[k]\nfor i in range(0,m):\n if temp[i][1]==n:\n tempa=str(n)\n tempj=str(j)\n temp[i][1]=tempa.zfill(6)\n temp[i][2]=tempj.zfill(6)\n j=j+1\n else:\n k=k+1\n if k>=len(tempn):\n break\n n=tempn[k]\n j=1\n tempa=str(n)\n tempj=str(j)\n temp[i][1]=tempa.zfill(6)\n temp[i][2]=tempj.zfill(6)\n j=j+1\ntemp.sort(key=lambda x: x[0])\nfor i in range(0,m):\n print(temp[i][1]+temp[i][2])']
['Wrong Answer', 'Accepted']
['s258926575', 's933016525']
[39404.0, 37448.0]
[874.0, 856.0]
[550, 661]
p03221
u634208461
2,000
1,048,576
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.
["\n\n#include <map>\n#include <algorithm>\n#include <iomanip>\nusing namespace std;\n\nint main()\n{\n int N, M; cin >> N >> M;\n\n vector< pair<int, int> > rawInput(M);\n vector<vector<int> > prifList(N);\n map<pair<int, int>, int> answer;\n\n for(int i = 0; i < M; ++i)\n {\n int P, Y; cin >> P >> Y;\n rawInput.at(i) = make_pair(P, Y);\n prifList.at(P - 1).push_back(Y);\n answer[make_pair(P, Y)] = 0;\n }\n\n for(int i = 0; i < N; ++i)\n {\n sort(prifList.at(i).begin(), prifList.at(i).end());\n for(int j = 0; j < prifList.at(i).size(); ++j)\n {\n answer[make_pair(i+1, prifList[i][j])] = j + 1;\n }\n }\n for(int i = 0; i < M; ++i)\n {\n cout << setw(6) << setfill('0') << rawInput.at(i).first;\n cout << setw(6) << setfill('0') << answer[rawInput.at(i)] << '\\n';\n }\n return 0;\n}\n", 'N, M = map(int, input().split())\nA = []\nPlst = [list() for _ in range(N)]\ndic = {}\nfor i in range(M):\n P, Y = map(int, input().split())\n A.append([i, P, Y])\n Plst[P - 1].append(Y)\n dic[(P, Y)] = 0\nfor i in range(N):\n Plst[i].sort()\n for j in range(len(Plst[i])):\n s = str(str(i + 1).zfill(6) + str(j + 1).zfill(6))\n dic[(i, Plst[i][j])] = s\nfor e in A:\n print(dic[(e[1] - 1, e[2])])\n']
['Runtime Error', 'Accepted']
['s458488637', 's152221708']
[2940.0, 71248.0]
[17.0, 972.0]
[910, 418]
p03221
u635272634
2,000
1,048,576
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.
["n, m = list(map(int, input().split()))\ntmps = [[] for _ in range(n)]\npyxs = []\n\nfor i in range(m):\n p, y = list(map(int, input().split()))\n pyxs.append([p, y, i])\n\npyxs.sort(key = lambda x: x[1])\n\nnum = [0] * (n+1)\nans = []*m\n\nfor p, y, x in pyxs:\n ans[i] = '{:06}'.format(p) + '{:06}'.format(num[p]+1)\n num[p] += 1\n\nfor s in ans:\n print(s)", "n, m = list(map(int, input().split()))\ntmp = [[0 for i in range(1)] for j in range(m)]\npys = []\nfor i in range(0, m):\n p, y = list(map(int, input().split()))\n tmp[p].append(y)\n pys.append([p, y])\n\nprint(tmp)\n\nttmp = [[0 for i in range(1)] for j in range(m)]\n\nfor i in range(m):\n ttmp[i] = sorted(tmp[i])\n\nprint(ttmp)\n\nfor py in pys:\n p, y = py\n yindex = ttmp[p].index(y)\n print('{:06}'.format(p) + '{:06}'.format(yindex))", "n, m = list(map(int, input().split()))\ntmps = [[] for _ in range(n)]\npyxs = []\n\nfor i in range(m):\n p, y = list(map(int, input().split()))\n pyxs.append([p, y, i])\n\npyxs.sort(key = lambda x: x[1])\n\nnum = [0] * (n+1)\nans = [None]*m\n\nfor p, y, x in pyxs:\n ans[x] = '{:06}'.format(p) + '{:06}'.format(num[p]+1)\n num[p] += 1\n\nfor s in ans:\n print(s)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s398999122', 's929898560', 's119394500']
[32108.0, 52788.0, 39620.0]
[468.0, 2106.0, 701.0]
[355, 442, 359]
p03221
u635974378
2,000
1,048,576
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.
["N, M = list(map(int, input().split()))\nPYs = {}\nfor _ in range(M):\n p, y = list(map(int, input().split()))\n if p not in PYs:\n PYs[p] = []\n PYs[p].append(y)\n\nfor p in sorted(PYs.keys()):\n str_p = '{}'.format(p).zfill(6)\n for idx, c in enumerate(sorted(PYs[p])):\n print(str_p + '{}'.format(idx + 1).zfill(6))\n\n\n\n", "N, M = list(map(int, input().split()))\n\nPYs = {}\n\npy2nummap = {}\npy2 = []\nfor _ in range(M):\n p, y = list(map(int, input().split()))\n if p not in PYs:\n PYs[p] = []\n PYs[p].append(y)\n py2nummap[(p,y)] = ''\n py2.append((p,y))\n\nfor p in sorted(PYs.keys()):\n str_p = '{}'.format(p).zfill(6)\n for idx, c in enumerate(sorted(PYs[p])):\n py2nummap[(p,c)] = (str_p + '{}'.format(idx + 1).zfill(6))\n\n\nfor y in py2:\n # print(y)\n print(py2nummap[y])\n# print(py2nummap)\n# print(PYs)\n"]
['Wrong Answer', 'Accepted']
['s436124902', 's408126207']
[34960.0, 61196.0]
[760.0, 991.0]
[339, 511]
p03221
u642012866
2,000
1,048,576
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.
['N, M = map(int, input().split())\nken = [[] for _ in range(N)]\nshi = [tuple(map(int, input().split())) for _ in range(M)]\nfor s1, s2 in shi:\n ken[s1-1].append(s2)\nfor k in ken:\n k.sort()\nfor s1, s2 in shi:\n print("{:06}{:06}".format(s1, ken[s1-1].index(s2+1)))', 'from operator import itemgetter\nN, M = map(int, input().split())\niPY = [0]*M\nres = [0]*M\nfor i in range(M):\n P, Y = map(int, input().split())\n iPY[i] = (i, P, Y)\niPY.sort(key=itemgetter(2))\niPY.sort(key=itemgetter(1))\nj = 1\np = iPY[0][1]\nfor i, P, Y in iPY:\n if P != p:\n j = 1\n p = P\n res[i] = "{:06}{:06}".format(P, j)\n j += 1\nfor s in res:\n print(s)']
['Runtime Error', 'Accepted']
['s441904843', 's181977802']
[28224.0, 29640.0]
[396.0, 627.0]
[268, 383]
p03221
u645250356
2,000
1,048,576
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.
['N,M = map(int,input().split())\npy_list = []\nd = dict()\nfor i in range(M):\n p,y = map(int,input().split())\n py_list.append([p,y])\npy_sorted = sorted(py_list)\np_temp = py_sorted[0][0]\ncount = 1\nfor p,y in py_sorted:\n if p_temp != p:\n p_temp = p\n count = 1\n d[(p,y)] = count\n count += 1\n\nfor i in range(M):\n s = d[(py_list[i][0],py_list[i][-1])]\n s = str(s)\n print(str(py_list[i][0]).zfill(6),s.zfill(6))\n\n', "import sys\nn,m = map(int,input().split())\npy = []\nd = dict()\n\nfor i in range(m):\n (a,b) = map(int,input().split())\n py.append((a,b))\nsort_py = sorted(py)\n\ntmp_p = sort_py[0][0]\ncnt = 1\nfor p,y in sort_py:\n if p == tmp_p:\n d[(p,y)] = cnt\n else:\n tmp_p = p\n cnt = 1\n d[(p,y)] = cnt\n cnt += 1\nfor i in range(m):\n print('{0} {1}'.format(str(py[i][0]).zfill(6), str(d[py[i]]).zfill(6))) \n", 'N,M = map(int,input().split())\npy_list = []\nd = dict()\nfor i in range(M):\n p,y = map(int,input().split())\n py_list.append([p,y])\npy_sorted = sorted(py_list)\np_temp = py_sorted[0][0]\ncount = 1\nfor p,y in py_sorted:\n if p_temp != p:\n p_temp = p\n count = 1\n d[(p,y)] = count\n count += 1\n\nfor i in range(M):\n s = d[(py_list[i][0],py_list[i][-1])]\n s = str(s)\n print(str(py_list[i][0]).zfill(6),s.zfill(6))\n\n', "import sys\nn,m = map(int,input().split())\npy = []\nd = dict()\n\nfor i in range(m):\n (a,b) = map(int,input().split())\n py.append((a,b))\nsort_py = sorted(py)\n\ntmp_p = sort_py[0][0]\ncnt = 1\nfor p,y in sort_py:\n if p == tmp_p:\n d[(p,y)] = cnt\n else:\n tmp_p = p\n cnt = 1\n d[(p,y)] = cnt\n cnt += 1\nprint(d)\nfor i in range(m):\n print('{0} {1}'.format(str(py[i][0]).zfill(6), str(d[py[i]]).zfill(6))) \n", "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,math,itertools,fractions\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,m = inpl()\nd = dict()\nz = []\nres = [None] * m\nfor i in range(m):\n a,b = inpl()\n d[(a,b)] = i\n z.append([a,b])\nz.sort(key=lambda x:x[1])\nz.sort(key=lambda x:x[0])\n# print(z)\ncnt = 0\nnow = z[0][0]\nfor i,t in enumerate(z):\n ind = d[(t[0],t[1])]\n if now == t[0]:\n cnt += 1\n res[ind] = [now,cnt]\n else:\n cnt = 1\n now = t[0]\n res[ind] = [now,cnt]\n\nfor a,b in res:\n print(str(a).zfill(6) + str(b).zfill(6))"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s160183312', 's472114003', 's608500398', 's646301708', 's417571740']
[38028.0, 34892.0, 38028.0, 42452.0, 52492.0]
[823.0, 741.0, 827.0, 834.0, 900.0]
[442, 432, 442, 441, 764]
p03221
u647213752
2,000
1,048,576
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.
['N, M = map(int, input().split())\np = list()\nd = dict()\nfor i in range(M):\n inp = map(int, input().split())\n p.append(inp)\n if inp[0] in d:\n d[inp[0]].append(inp[1])\n else:\n d[inp[0]] = [inp[1]]\nfor i in d:\n d[i].sort()\nfor i, j in p:\n print("{:06d}{:06d}".format(i, d[i].index(j)+1))', 'N, M = map(int, input().split())\np = list()\ny = list()\nd = dict()\nfor i in range(N):\n inp_p, inp_y = map(int, input().split())\n p.append(inp_p)\n y.append(inp_y)\n if p in d:\n d[p].append(y)\n else:\n d[p] = [y]\nfor i in d:\n d[i] = sorted(d[i])\nfor i, j in zip(p, y):\n print("{:06d}{:06d}".format(i, d[i].index(j)+1))', 'N, M = map(int, input().split())\np = [[] for i in range(M)]\ncounter = [0] * N\nans = [""] * M\n\nfor i in range(M):\n k, y = map(int, input().split())\n p[i] = [k, y, i]\n\np.sort(key=lambda x:x[1])\nfor k, y, i in p:\n counter[k-1] += 1\n ans[i] = "{:06d}{:06d}".format(k, counter[k-1])\n\nfor i in ans:\n print(i)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s351517960', 's945520108', 's011238857']
[3064.0, 3064.0, 32248.0]
[17.0, 17.0, 617.0]
[315, 348, 317]
p03221
u649558044
2,000
1,048,576
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.
['n, m = map(int, input().split())\np, y = [0] * m, [0] * m\nsort_year = [0] * m\ninitial_index, count_city = [0] * n, [0] * n\ntmp_counter = [0] * n \nfor i in range(m):\n p[i], y[i] = map(int, input().split())\n count_city[p[i] - 1] += 1\nfor j in range(1, n):\n \tinitial_index[j] = initial_index[j] + count_city[j - 1]\nfor i in range(m):\n sort_year[initial_index[p[i] - 1] + tmp_counter[p[i] - 1]] = y[i]\n tmp_counter[p[i] - 1] += 1\nfor j in range(n):\n sort_year[initial_index[j] : initial_index[j] + count_city[j - 1]].sort()\nfor i in range(m):\n x = sort_year.index(y[i]) - initial_index[p[i] - 1] + 1\n print(str(p[i]).zfill(6) + str(x).zfill(6))\n', 'n, m = map(int, input().split())\np, y = [0] * m, [0] * m\nsort_year = [0] * m\ninitial_index, count_city = [0] * n, [0] * n\ntmp_counter = [0] * n \nfor i in range(m):\n p[i], y[i] = map(int, input().split())\n count_city[p[i] - 1] += 1\nfor j in range(1, n):\n \tinitial_index[j] = initial_index[j] + count_city[j - 1]\nfor i in range(m):\n sort_year[initial_index[p[i] - 1] + tmp_counter[p[i] - 1]] = y[i]\n tmp_counter[p[i] - 1] += 1\nfor j in range(n):\n sort_year[initial_index[j] : initial_index[j] + count_city[j - 1]].sort()\nfor i in range(m):\n x = sort_year.index(y[i]) - initial_index[p[i] - 1] + 1\n print(str(p[i]).zfill(8) + str(x).zfill(8))\n', 'n, m = map(int, input().split())\np, y = [0] * m, [0] * m\nsort_year = [0] * m\ninitial_index, count_city = [0] * n, [0] * n\ntmp_counter = [0] * n \nfor i in range(m):\n p[i], y[i] = map(int, input().split())\n count_city[p[i] - 1] += 1\nfor j in range(1, n):\n \tinitial_index[j] = initial_index[j - 1] + count_city[j - 1]\nfor i in range(m):\n sort_year[initial_index[p[i] - 1] + tmp_counter[p[i] - 1]] = y[i]\n tmp_counter[p[i] - 1] += 1\nfor j in range(n):\n sort_year[initial_index[j] : initial_index[j] + count_city[j - 1]] = sorted(sort_year[initial_index[j] : initial_index[j] + count_city[j - 1]])\nfor i in range(m):\n x = sort_year.index(y[i]) - initial_index[p[i] - 1] + 1\n print(str(p[i]).zfill(6) + str(x).zfill(6))', 'import bisect\ndef index(alist, x):\n i = bisect.bisect_left(alist, x)\n if i != len(alist) and alist[i] == x:\n return i\n raise ValueError\n\nn, m = map(int, input().split())\np, y = [0] * m, [0] * m\nyear_list = [[] for _ in range(n)]\nfor i in range(m):\n p[i], y[i] = map(int, input().split())\n year_list[p[i] - 1].append(y[i])\nfor j in range(n):\n year_list[j].sort()\nfor i in range(m):\n x = index(year_list[p[i] - 1], y[i]) + 1\n print(str(p[i]).zfill(6) + str(x).zfill(6))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s279427127', 's579811324', 's998299032', 's238236457']
[15280.0, 15280.0, 19264.0, 24064.0]
[2104.0, 2104.0, 2105.0, 697.0]
[662, 662, 735, 498]
p03221
u652150585
2,000
1,048,576
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.
["import sys\ninput=sys.stdin.readline\n\nn,m=map(int,input().split())\nl=[list(map(int,input().split())) for _ in range(m)]\nprint(l)\nfor i in range(m):\n n=1\n for j in range(m):\n if l[i][0]==l[j][0] and l[i][1]>l[j][1]:\n n+=1\n print(str('%06d'%l[i][0])+str('%06d'%n))", "import sys\ninput=sys.stdin.readline\n\nn,m=map(int,input().split())\nl=[list(map(int,input().split())) for _ in range(m)]\n#print(l)\nli=[[]*n for _ in range(n)]\nlis=sorted(l)\nfor i in lis:\n li[i[0]-1].append(i[1])\n print(li)\nfor i in l:\n a=li[i[0]-1].index(i[1])\n print(str('%06d'%i[0])+str('%06d'%(a+1))) ", "n,m=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(m)]\ns=[]\nfor i in enumerate(l):\n s.append(i)\ns=sorted(s,key=lambda x:(x[1][0],x[1][1]))\n#print(s)\na=1\nfor i in range(m):\n if i==0:\n s[0][1][1]=1\n elif s[i][1][0]==s[i-1][1][0]:\n a+=1\n s[i][1][1]=a\n elif s[i][1][0]!=s[i-1][1][0]:\n a=1\n s[i][1][1]=a\n#print(s)\ns=sorted(s,key=lambda x:x[0])\n#print(s)\nfor i in s:\n print('%06d'%i[1][0]+'%06d'%i[1][1])"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s556905196', 's836605308', 's299847174']
[33392.0, 157500.0, 46748.0]
[2105.0, 2106.0, 799.0]
[288, 321, 475]
p03221
u655227110
2,000
1,048,576
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.
["n, m = map(int, input().split())\n\ncity_list = []\nfor i in range(m):\n\tp, y = map(int, input().split())\n\tcity_list.append([i, p, y, 0])\n\nprint(city_list)\ncity_list = sorted(city_list, key = lambda x: x[2])\nprint(city_list)\ncity_list = sorted(city_list, key = lambda x: x[1])\nprint(city_list)\n\nnowp = 1\nindex = 1\nfor city in city_list:\n\tif city[1] == nowp:\n\t\tcity[3] = index\n\t\tindex += 1\n\telse:\n\t\tnowp = city[1]\n\t\tindex = 1\n\t\tcity[3] = index\n\t\tindex += 1\n\nprint(city_list)\ncity_list = sorted(city_list, key = lambda x: x[0])\nprint(city_list)\n\nfor city in city_list:\n\tkami_str = '0' * (6 - len(str(city[1]))) + str(city[1])\n\tshimo_str = '0' * (6 - len(str(city[3]))) + str(city[3])\n\tanswer = kami_str + shimo_str\n\tprint(answer)\n", "n, m = map(int, input().split())\n\ncity_list = []\nfor i in range(m):\n\tp, y = map(int, input().split())\n\tcity_list.append([i, p, y, 0])\n\ncity_list = sorted(city_list, key = lambda x: x[2])\ncity_list = sorted(city_list, key = lambda x: x[1])\n\nnowp = 1\nindex = 1\nfor city in city_list:\n\tif city[1] == nowp:\n\t\tcity[3] = index\n\t\tindex += 1\n\telse:\n\t\tnowp = city[1]\n\t\tindex = 1\n\t\tcity[3] = index\n\t\tindex += 1\n\ncity_list = sorted(city_list, key = lambda x: x[0])\n\nfor city in city_list:\n\tkami_str = '0' * (6 - len(str(city[1]))) + str(city[1])\n\tshimo_str = '0' * (6 - len(str(city[3]))) + str(city[3])\n\tanswer = kami_str + shimo_str\n\tprint(answer)\n"]
['Wrong Answer', 'Accepted']
['s287857147', 's022296713']
[53424.0, 30328.0]
[1185.0, 773.0]
[724, 639]
p03221
u656995812
2,000
1,048,576
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.
["n, m = map(int, input().split())\ntmp = [list(map(int, input().split())) for i in range(m)]\ncity = [[] for i in range(n+1)]\nanswers = [''] * m\n\nfor i, (pref, year) in enumerate(tmp):\n city[pref].append([year, i])\nprint(city)\n\nfor i in range(n+1):\n for j, (year, index) in enumerate(sorted(city[i])):\n ans = str(i).zfill(6) + str(j+1).zfill(6)\n answers[index] = ans\n\nprint(*answers, sep='\\n')", "n, m = map(int, input().split())\ntmp = [list(map(int, input().split())) for i in range(m)]\ncity = [[] for i in range(n+1)]\nanswers = [''] * m\n\nfor i, (pref, year) in enumerate(tmp):\n city[pref].append([year, i])\n\nfor i in range(n+1):\n for j, (year, index) in enumerate(sorted(city[i])):\n ans = str(i).zfill(6) + str(j+1).zfill(6)\n answers[index] = ans\n\nprint(*answers, sep='\\n')"]
['Wrong Answer', 'Accepted']
['s244101199', 's869195584']
[58796.0, 56624.0]
[916.0, 803.0]
[410, 398]
p03221
u665038048
2,000
1,048,576
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.
["n, m = map(int, input().split())\npy = [list(map(int, input().split())) for _ in range(m)]\nans_dict = {}\nans_lst = []\nfor i in range(m):\n if py[i][0] in ans_dict.keys():\n ans_lst.append('{:0=6}'.format(py[i][0]) +\n '{:0=6}'.format(py[i][0]-1))\n print(ans_lst[-1])\n else:\n ans_lst.append('{:0=6}'.format(py[i][0]) +\n '000001')\n print(ans_lst[-1])", "n, m = map(int, input().split())\npy = [list(map(int, input().split())) for _ in range(m)]\nans_dict = {}\nans_lst = []\nfor i in range(m):\n if py[i][0] in ans_dict.keys():\n ans_dict[py[i][0]] += 1\n ans_lst.append('{:0=6}'.format(py[i][0]) +\n '{:0=6}'.format(ans_dict[py[i][0]]))\n print(ans_lst[-1])\n else:\n ans_dict[py[i][0]] = 1\n ans_lst.append('{:0=6}'.format(py[i][0]) +\n '000001')\n print(ans_lst[-1])", "n, m = map(int, input().split())\nl = []\nk = ['_'] * m\nx = [1] * (n+1)\nfor i in range(m):\n a, b = map(int, input().split())\n l.append([i, a, b])\ny = sorted(l, key=lambda c: c[2])\nfor i in y:\n k[i[0]] = str(i[1]).zfill(6) + str(x[i[1]]).zfill(6)\n x[i[1]] += 1\nfor i in k:\n print(i)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s289192291', 's965776274', 's595241771']
[35960.0, 44464.0, 32972.0]
[515.0, 625.0, 619.0]
[422, 493, 294]
p03221
u665873062
2,000
1,048,576
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.
["N,M = map(int,input().split())\nPYlist = []\nfor i in range(M):\n PYlist_ele = list(map(int,input().split()))\n PYlist_ele.append(i+1)\n PYlist.append(PYlist_ele)\nPYlist.sort()\ncheck = 0\ncount = 0\nP_id = []\nfor i in range(M):\n if check == PYlist[i][0]:\n count +=1\n else:\n count = 1\n idup = '{:06}'.format(PYlist[i][0])\n iddown = '{:06}'.format(check)\n P_id.append([str(idup)+str(iddown),PYlist[i][2]])\nP_id.sort(key=lambda x: x[1])\nfor ans in P_id:\n print(ans[0])", "N,M = map(int,input().split())\nPYlist = []\nfor i in range(M):\n PYlist_ele = list(map(int,input().split()))\n PYlist_ele.append(i+1)\n PYlist.append(PYlist_ele)\nPYlist.sort()\ncheck = 0\ncount = 0\nP_id = []\nfor i in range(M):\n if check == PYlist[i][0]:\n count +=1\n else:\n count = 1\n check = PYlist[i][0]\n idup = '{:06}'.format(PYlist[i][0])\n iddown = '{:06}'.format(count)\n P_id.append([str(idup)+str(iddown),PYlist[i][2]])\nP_id.sort(key=lambda x: x[1])\nfor ans in P_id:\n print(ans[0])"]
['Wrong Answer', 'Accepted']
['s273430915', 's455692866']
[47072.0, 46000.0]
[946.0, 971.0]
[499, 528]
p03221
u666198201
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA=[]\ncount=[1]*100000\nnumber=0\nfor i in range(M):\n a, b, = map(int, input().split())\n A.append([b, a])\n\nA.sort()\n\nfor i in range(M):\n number=A[i][1]*1000000+count[int(A[i][1])]\n print(str(number).zfill(12))\n count[int(A[i][1])] +=1\n\n', 'N, M = map(int, input().split())\nA=[]\ncount=[1]*1000000\nans=[]\nfor i in range(M):\n a, b, = map(int, input().split())\n A.append([b, a, i])\n\nA.sort()\n\nfor i in range(M):\n number=A[i][1]*1000000+count[int(A[i][1])]\n ans.append([A[i][2],str(number).zfill(12)])\n count[int(A[i][1])] +=1\nans.sort()\n\nfor i in range(M):\n print(ans[i][1])\n\n']
['Runtime Error', 'Accepted']
['s464049785', 's553159480']
[21824.0, 48828.0]
[647.0, 903.0]
[281, 350]
p03221
u667024514
2,000
1,048,576
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.
['from operator import itemgetter\nn,m = map(int,input().split())\nlis = []\nans = [0 for i in range(m)]\nnum = [0 for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n lis.append([i,a,b])\nlis.sort(key=itemgetter(2))\nfor i in range(m):\n num[lis[i][1]-1] += 1\n cou = 6-(lis[i][1] // 10)\n co = 6-(num[lis[i][1]-1] // 10)\n ans[lis[i][0]] = "0" * cou + str(lis[i][1]) + "0" * co + str(num[lis[i][1]-1])\nfor i in range(m):print(ans[i])', 'n,m =map(int,input().split())\nlis = [list(map(int,input().split())) for i in range(m)]\nfor i in range(m):\n lis[i].append(i)\nlis.sort()\ncnt = 1\nans = []\nans.append([lis[0][-1],format(lis[0][0]).zfill(6)+format(1).zfill(6)])\nfor i in range(m-1):\n if lis[i][0] == lis[i+1][0]:\n cnt += 1\n ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])\n else:\n cnt = 1\n ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])\nans.sort(key = lambda x:x[0])\nfor i,x in ans:\n print(x)']
['Wrong Answer', 'Accepted']
['s501130602', 's033895726']
[32120.0, 46008.0]
[656.0, 888.0]
[447, 551]
p03221
u667458133
2,000
1,048,576
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.
["import bisect\n\nN, M = map(int, input().split())\nPY = []\narray = [[] for _ in range(N)]\n\nfor _ in range(M):\n P, Y = map(int, input().split())\n PY.append([P, Y])\n array[P-1].append(Y)\n\nfor p, y in PY:\n n = bisect.bisect_left(array[p-1], y) + 1\n print('%06d%06d' % (p, n))\n", "import bisect\n\nN, M = map(int, input().split())\nPY = []\narray = [[] for _ in range(N)]\n\nfor _ in range(M):\n P, Y = map(int, input().split())\n PY.append([P, Y])\n array[P-1].append(Y)\n \nfor i in range(N):\n array[i].sort()\n\nfor p, y in PY:\n n = bisect.bisect_left(array[p-1], y) + 1\n print('%06d%06d' % (p, n))\n"]
['Wrong Answer', 'Accepted']
['s068414903', 's612736298']
[32792.0, 32792.0]
[584.0, 637.0]
[285, 329]
p03221
u669382434
2,000
1,048,576
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.
["from operator import itemgetter\n\nN,M=map(int,input().split())\nPY=[]\nP=[[] for i in range(N)]\nans=[0 for i in range(M)]\nfor i in range(M):\n PYi=list(map(int,input().split()))\n PY.append(PYi)\n P[PYi[0]-1].append([i,PYi[1]])\n\nfor i in range(N):\n P[i]=sorted(P[i], key=itemgetter(1))\n\nfor i in range(N):\n for j in range(len(P[i])):\n ans[P[i][j][0]]=j+1\n\nprint(P)\nprint(ans)\nprint(N)\nfor i in range(M):\n a=format(PY[i][0],'06x')\n b=format(ans[i],'06x')\n print(a+b)", "from operator import itemgetter\n\nN,M=map(int,input().split())\nPY=[]\nans=[0 for i in range(M)]\ncc=[0 for i in range(N)]\nfor i in range(M):\n PYi=list(map(int,input().split()))\n PY.append([i,PYi[0],PYi[1]])\n \nPY=sorted(PY, key=itemgetter(2))\n\nfor i in range(M):\n cc[PY[i][1]-1]+=1\n ans[PY[i][0]]=cc[PY[i][1]-1]\n\nfor i in range(M):\n a=format(PY[i][1],'06d')\n b=format(ans[i],'06d')\n print(a+b)", "from operator import itemgetter\n\nN,M=map(int,input().split())\nPY=[]\nans=[0 for i in range(M)]\ncc=[0 for i in range(N)]\nfor i in range(M):\n PYi=list(map(int,input().split()))\n PY.append([i,PYi[0],PYi[1]])\n \nPY=sorted(PY, key=itemgetter(2))\n\nfor i in range(M):\n cc[PY[i][1]-1]+=1\n ans[PY[i][0]]=format(PY[i][1],'06d')+format(cc[PY[i][1]-1],'06d')\n\nfor i in range(M):\n print(ans[i])"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s167782772', 's614579362', 's735368092']
[57708.0, 29492.0, 34712.0]
[1095.0, 736.0, 739.0]
[490, 414, 398]
p03221
u669812251
2,000
1,048,576
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.
['# -*- coding: utf-8 -*-\n\ndef main():\n N, M = [int(i) for i in input().split()]\n cities = []\n for i in range(M):\n p, y = map(int, input().split())\n cities.append([p, y])\n cities.sort()\n\n before = 0\n num = 1\n for p, y in cities:\n if before == p:\n num +=1\n else:\n num = 1\n before = p\n\n print(str(p).zfill(6) + str(num).zfill(6))\n\n\n\nif __name__ == "__main__":\n main()\n', '# -*- coding: utf-8 -*-\n\ndef main():\n N, M = [int(i) for i in input().split()]\n cities = []\n\n for i in range(M):\n p, y = map(int, input().split())\n cities.append([p, y, i])\n\n cities.sort()\n ans = []\n\n num = 0\n before = cities[0][0]\n\n for i in range(M):\n if before != cities[i][0]:\n num = 1\n before = cities[i][0]\n else:\n num += 1\n ans.append([cities[i][0], num, cities[i][2]])\n\n ans.sort(key=lambda x:x[2])\n for a in ans:\n s = str(a[0]).zfill(6) + str(a[1]).zfill(6)\n print(s)\n\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s399025808', 's540154734']
[21072.0, 37920.0]
[569.0, 830.0]
[457, 631]
p03221
u673338219
2,000
1,048,576
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.
['from operator import itemgetter\nn,m = map(int,input().split())\npy = [list(map(int,input().split())) for _ in range(m)]\ncopy = py\nsorted(py, key=itemgetter(1))\na = [1]*n\nb = [0]*m\nfor i in range(m):\n b[i] = a[py[i][0]-1]\n a[py[i][0]-1] += 1\nfor j in range(m):\n x = py.index(copy[j])\n print(1000000*copy[j][0]+b[x])\n \n \n \n', 'n,m = map(int,input().split())\na = [[] for _ in range(n)]\nfor i in range(1,m+1):\n pi,yi = map(int,input().split())\n a[pi-1].append((yi,i))\nans = [0 for _ in range(m)]\nfor i in range(n):\n if a[i]:\n a[i].sort(key=lambda x:x[0])\n c = (i+1)*10**6\n for j in range(len(a[i])):\n ans[a[i][j][1]-1] = c + j+1\nfor xx in ans:\n xs = str(xx)\n xs = "0"*(12-len(xs)) + xs\n print(xs)\n \n\n\n ']
['Wrong Answer', 'Accepted']
['s300512961', 's592314204']
[34184.0, 33556.0]
[2106.0, 701.0]
[327, 395]
p03221
u673361376
2,000
1,048,576
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.
["import bisect\n\nn, m = map(int, input().split())\npy_dict = {}\ncityi_by_year = []\nfor i in range(m):\n p, y = map(int, input().split())\n if p not in py_dict:py_dict[p] = [y]\n else:py_dict[p].append(y)\n cityi_by_year.append([p,y])\n\nfor p, y in cityi_by_year:\n idx = bisect.bisect_left(py_dict[p],y)\n print('0'*(6-len(str(p))) + str(p) + '0'*(6-len(str(idx+1))) + str(idx+1))\n", 'import collections\nimport bisect\nn,m=map(int,input().split())\np=[[int(j) for j in input().split()] for i in range(m)]\na=collections.defaultdict(list)\nfor x,y in sorted(p):\n a[x]+=[y]\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))']
['Wrong Answer', 'Accepted']
['s787298129', 's318822290']
[36660.0, 41012.0]
[707.0, 686.0]
[377, 255]
p03221
u677312543
2,000
1,048,576
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.
['n, m = map(int, input().split())\npy = [[i, list(map(int, input().split()))] for i in range(m)]\n\npy = sorted(py, key=lambda x: (x[1][0],x[1][1]))\nprint(py)\n\ncnt = 1\nprev_p = 0\nfor i in py:\n p, y = i[1][0], i[1][1]\n if prev_p == p:\n cnt += 1\n else:\n cnt = 1\n\n ans = str(p).zfill(6) + str(cnt).zfill(6)\n i.append(ans)\n prev_p = p\n\npy = sorted(py, key=lambda x: x[0])\nfor i in py:\n print(i[2])', 'n, m = map(int, input().split())\npyidx = []\nfor i in range(m):\n py_tmp = list(map(int, (input()).split() + [str(i)]))\n pyidx += [py_tmp]\n\npyidx = sorted(pyidx, key=lambda x: x[1])\n\ncounter = [1] * n\n\nans = []\nfor i, pyx in enumerate(pyidx):\n p, y, idx = pyx[0], pyx[1], pyx[2]\n x_new = counter[p-1]\n counter[p-1] += 1\n ans.append([str(p).zfill(6) + str(x_new).zfill(6), idx])\n\nans = sorted(ans, key=lambda x: x[1])\nfor i in ans:\n print(i[0])']
['Wrong Answer', 'Accepted']
['s196437660', 's710577532']
[53220.0, 47136.0]
[1028.0, 1064.0]
[424, 462]
p03221
u677705680
2,000
1,048,576
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.
['"""\n\n\n\n"""\n\nN, M = map(int, input().split())\n\ncity = [list(map(int, input().split())) + [i] + [0] for i in range(M)]\n\ncity.sort(key=lambda x: (x[0], x[1]))\nprint(city)\nfor m in range(M):\n if m == 0:\n city[m][3] = 1\n elif city[m][0] != city[m - 1][0]:\n city[m][3] = 1\n else:\n city[m][3] = city[m - 1][3] + 1\n\ncity.sort(key=lambda x: x[2])\n\nfor m in range(M):\n print(str(city[m][0]).zfill(6) + str(city[m][3]).zfill(6))\n ', '"""\n\n\n\n"""\n\nN, M = map(int, input().split())\n\ncity = [list(map(int, input().split())) + [i] + [0] for i in range(M)]\n\ncity.sort(key=lambda x: (x[0], x[1]))\n\nfor m in range(M):\n if m == 0:\n city[m][3] = 1\n elif city[m][0] != city[m - 1][0]:\n city[m][3] = 1\n else:\n city[m][3] = city[m - 1][3] + 1\n\ncity.sort(key=lambda x: x[2])\n\nfor m in range(M):\n print(str(city[m][0]).zfill(6) + str(city[m][3]).zfill(6))\n ']
['Wrong Answer', 'Accepted']
['s163659741', 's103086056']
[46592.0, 39812.0]
[919.0, 831.0]
[493, 482]
p03221
u678167152
2,000
1,048,576
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.
["N, M = map(int, input().split())\npref = [[] for _ in range(N)]\nP,Y = [0]*M,[0]*M\nfor i in range(M):\n P[i],Y[i] = map(int, input().split())\n pref[P[i]-1].append(Y[i])\n\nfor i in range(N):\n pref[i].sort()\n\nfrom bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort\n\ndef solve(P,Y,pref):\n ans = []\n for p, y in zip(P,Y):\n ind = bisect_left(Y,y)+1\n num = '0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(ind)))+str(ind)\n ans.append(num)\n return ans\nprint(*solve(P,Y,pref),sep='\\n')", "N, M = map(int, input().split())\nfrom bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort\ndef solve(N,M):\n pref = [[] for _ in range(N)]\n P = [0]*M\n Y = [0]*M\n for i in range(M):\n P[i],Y[i] = map(int, input().split())\n pref[P[i]-1].append(Y[i])\n for i in range(N):\n pref[i].sort()\n ans = []\n for i in range(M):\n ind = bisect_left(pref[P[i]-1],Y[i])\n ans.append('0'*(6-len(str(P[i])))+str(P[i])+'0'*(6-len(str(ind+1)))+str(ind+1))\n return ans\nprint(*solve(N,M),sep='\\n')\n"]
['Wrong Answer', 'Accepted']
['s617409196', 's759665405']
[31988.0, 29920.0]
[604.0, 625.0]
[537, 560]
p03221
u680851063
2,000
1,048,576
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.
["n, m = map(int, input().split())\nl = [list(map(int, input().split(' '))) for _ in range(m)]\nl = sorted(l)\n#print(n,m)\n#print(l)\n\nx = l[0][0]\ny = 1\n#print(x)\n\nfor i in range(m):\n if l[i][0] == x:\n l[i][1] = y\n y += 1\n else:\n y = 1\n l[i][1] = y\n y += 1\n x = l[i][0]\n#print(l)\n\nfor j in range(m):\n print(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))\n", "n, m = map(int, input().split())\nl = [list(map(int, input().split(' '))) for _ in range(m)]\n#print(l)\nl = sorted(l)\n#print(n,m)\n#print(l)\n\nx = l[0][0]\ny = 1\n#print(x)\n\nfor i in range(m):\n if l[i][0] == x:\n l[i][1] = y\n y += 1\n else:\n y = 1\n l[i][1] = y\n y += 1\n x = l[i][0]\n#print(l)\nl = sorted(l, key=lambda x:(x[1]))\n#print(l)\n#l = list(reversed(l))\n#print(l)\nz = []\nfor j in range(m):\n z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))\n#z.sort()\nfor k in range(m):\n print(z[k])", "n, m = map(int, input().split())\nl = [list(map(int, input().split(' '))) for _ in range(m)]\n\nfor v in range(m):\n l[v].append(v)\n\nl = sorted(l)\n\n\nx = l[0][0]\ny = 1\n\nfor i in range(m):\n if l[i][0] == x:\n l[i][1] = y\n y += 1\n else:\n y = 1\n l[i][1] = y\n y += 1\n x = l[i][0]\n\nl = sorted(l, key=lambda i:(i[2]))\n\nz = []\nfor j in range(m):\n z.append(str(l[j][0]).rjust(6,'0') + str(l[j][1]).rjust(6,'0'))\n\nfor k in range(m):\n print(z[k])"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s022411337', 's042920485', 's529792499']
[28820.0, 37380.0, 39204.0]
[673.0, 760.0, 803.0]
[407, 548, 487]
p03221
u682467216
2,000
1,048,576
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.
['# coding=utf-8\nfrom math import floor, ceil, sqrt, factorial, log, gcd\nfrom itertools import accumulate, permutations, combinations, product, combinations_with_replacement\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush, heappushpop, heapify\nimport copy\nimport numpy as np\nimport sys\nINF = float(\'inf\')\nmod = 10**9+7\nsys.setrecursionlimit(10 ** 6)\n\n\ndef lcm(a, b): return a * b / gcd(a, b)\n\n# 1 2 3\n# a, b, c = LI()\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\n\n# a = I()\n\n\ndef I(): return int(sys.stdin.buffer.readline())\n\n\n# a, b = LS()\n\n\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\').split()\n\n# a = S()\n\n\ndef S(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\')\n\n# 2\n# 1\n# 2\n# [1, 2]\n\n\ndef IR(n): return [I() for i in range(n)]\n\n# 2\n# 1 2 3\n# 4 5 6\n# [[1,2,3], [4,5,6]]\n\n\ndef LIR(n): return [LI() for i in range(n)]\n\n# 2\n# abc\n\n\n\n\ndef SR(n): return [S() for i in range(n)]\n\n# 2\n\n\n\n\n\ndef LSR(n): return [LS() for i in range(n)]\n\n# 2\n# abcd\n# efgh\n# [[a,b,c,d], [e,f,g,h]]\n\n\ndef SRL(n): return [list(S()) for i in range(n)]\n\n\ndef main():\n n, m = LI()\n # py = LIR(m)\n lst = [[] for i in range(n)]\n for i in range(m):\n p, y = map(int, input().split())\n lst[p - 1].append(y)\n\n for i in range(n):\n if len(lst[i]) > 1:\n lst[i].sort()\n\n for pair in py:\n print(str(pair[0]*1000000+lst[pair[0]-1].index(pair[1])+1).zfill(12))\n\n\nif __name__ == "__main__":\n main()\n', '# coding=utf-8\nfrom math import floor, ceil, sqrt, factorial, log, gcd\nfrom itertools import accumulate, permutations, combinations, product, combinations_with_replacement\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush, heappushpop, heapify\nimport copy\nimport numpy as np\nimport sys\nINF = float(\'inf\')\nmod = 10**9+7\nsys.setrecursionlimit(10 ** 6)\n\n\ndef lcm(a, b): return a * b / gcd(a, b)\n\n# 1 2 3\n# a, b, c = LI()\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\n\n# a = I()\n\n\ndef I(): return int(sys.stdin.buffer.readline())\n\n\n# a, b = LS()\n\n\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\').split()\n\n# a = S()\n\n\ndef S(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\')\n\n# 2\n# 1\n# 2\n# [1, 2]\n\n\ndef IR(n): return [I() for i in range(n)]\n\n# 2\n# 1 2 3\n# 4 5 6\n# [[1,2,3], [4,5,6]]\n\n\ndef LIR(n): return [LI() for i in range(n)]\n\n# 2\n# abc\n\n\n\n\ndef SR(n): return [S() for i in range(n)]\n\n# 2\n\n\n\n\n\ndef LSR(n): return [LS() for i in range(n)]\n\n# 2\n# abcd\n# efgh\n# [[a,b,c,d], [e,f,g,h]]\n\n\ndef SRL(n): return [list(S()) for i in range(n)]\n\n\ndef main():\n n, m = LI()\n # py = LIR(m)\n lst = [[] for i in range(n)]\n ans = [0 for i in range(m)]\n\n for i in range(m):\n p, y = map(int, input().split())\n lst[p - 1].append((y, i))\n\n for i in range(n):\n if len(lst[i]) > 1:\n lst[i].sort()\n for j, pair in enumerate(lst[i]):\n ans[pair[1]] = str(i+1).zfill(6) + str(j + 1).zfill(6)\n\n for i in range(m):\n print(ans[i])\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s143812927', 's104387864']
[39980.0, 56600.0]
[331.0, 465.0]
[1624, 1718]
p03221
u682730715
2,000
1,048,576
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.
['# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nn, m = map(int, input().split())\np = defaultdict(lambda :defaultdict(int))\ne = [[int(i) for i in input().split()] for i in range(m)] \np_index = [0] * (100001)\nfor i in e:\n pp, yy = i[0], i[1]\n p_index[pp] += 1\n p[pp][yy] = p_index[pp]\n\nfor i in e:\n print("{:0=6}".format(i[0]) + "{:0=6}".format(p[i[0]][i[1]]))', '# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nn, m = map(int, input().split())\np = defaultdict(lambda :defaultdict(list))\ne = [[int(i) for i in input().split()] for i in range(m)] \np_index = defaultdict(int)\nfor i in e:\n pp, yy = i[0], i[1]\n p[pp][yy] = 0\n\nfor i in p:\n count = 0\n l = sorted(p[i])\n for j in l:\n count += 1\n p[i][j] += count\n\nfor i in e:\n print("{:0=6}".format(i[0]) + "{:0=6}".format(p[i[0]][i[1]]))']
['Wrong Answer', 'Accepted']
['s919502155', 's382028857']
[62220.0, 61536.0]
[720.0, 799.0]
[547, 627]
p03221
u687343821
2,000
1,048,576
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.
['import numpy as np\nN,M = map(int,input().split())\ndata=[]\nfor i in range(M):\n data.append(list(map(int,input().split(" "))))\n\narr = np.array(data)\nc1=np.arange(0,M)\narr=np.insert(arr,2,c1,axis=1)\n#arr_sort=arr[np.argsort(arr[:,0])]\narr_sort=arr[np.argsort(arr[:,1])]\narr_sort=arr_sort[np.argsort(arr_sort[:,0])]\n\nj=1\ni_prev=1\nres=[]\nk = 0\nfor i in arr_sort:\n if(int(i[0])!=i_prev):\n j=1\n #print("{:06}{:06}".format(i[0],j))\n test = "{:06}{:06}".format(i[0],j)\n arr_sort[k][1]= str(test)\n k+=1\n j+=1\n i_prev=i[0]\n\narr_sort=arr_sort[np.argsort(arr_sort[:,0])]\nfor i in arr_sort:\n print("{:012}".format(i[1]))', "import numpy as np\nN, M = map(int, input().split())\np_dict = {}\np = [0 for i in range(M)]\ny = [0 for i in range(M)]\ni_in_p = [0 for i in range(M)]\n \nfor i in range(M):\n p[i], y[i] = map(int, input().split())\n if p[i] not in p_dict:\n i_in_p[i] = 0\n p_dict[p[i]] = [y[i]]\n continue\n i_in_p[i] = len(p_dict[p[i]])\n p_dict[p[i]].append(y[i])\nfor key in p_dict.keys():\n p_dict[key] = np.array(p_dict[key]).argsort().argsort() + 1\nfor i in range(M):\n print('{:06d}{:06d}'.format(p[i], p_dict[p[i]][i_in_p[i]]))"]
['Wrong Answer', 'Accepted']
['s234628938', 's890185114']
[46504.0, 50020.0]
[1295.0, 1350.0]
[640, 543]
p03221
u688447129
2,000
1,048,576
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.
['n,m=map(int, input().split())\npl=[0]*m\nyl=[0]*m\ncl=[0]*m\nppl=[[] for j in range(n+1)]\nfor i in range(m):\n pl[i],yl[i] = map(int, input().split())\n ppl[pl[i]].append((yl[i], i))\n\nfor i in range(m):\n print("%06d%06d" % (pl[i], cl[i]))', 'n,m=map(int, input().split())\npl=[0]*m\nyl=[0]*m\ncl=[0]*m\n# ppl=[[] for j in range(n+1)]\nfor i in range(m):\n pl[i],yl[i] = map(int, input().split())\n\n\n# pl[i],yl[i] = map(int, input().split())\n# ppl[pl[i]].append((yl[i], i))\n\nfor i in range(m):\n print("%06d%06d" % (pl[i], cl[i]))', 'import bisect\nn,m=map(int, input().split())\npl=[0]*100000\nyl=[0]*100000\nol=[[] for i in range(100001)]\nfor i in range(m):\n pl[i],yl[i] = map(int, input().split())\n ol[pl[i]].append(yl[i])\nfor i in range(1,n+1):\n ol[i].sort()\nfor i in range(m):\n print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s247419008', 's735363637', 's309024697']
[34380.0, 13128.0, 24052.0]
[535.0, 399.0, 648.0]
[241, 313, 323]
p03221
u691896522
2,000
1,048,576
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.
['n, m = list(map(int, input().split()))\ndata = []\nfor i in range(m):\n data.append([i + 1] + list(map(int, input().split())))\ndata = sorted(data, key = lambda x: (x[1], x[2]))\n\nans = [[0,0,0] for i in range(m)]\n\npre = data[0][1]\nnum = 1\nfor i in range(m):\n if pre != data[i][1]:\n num = 1\n ans[i][0] = data[i][1]\n ans[i][1] = num\n else:\n ans[i][0] = data[i][1]\n ans[i][1] = num\n num += 1\n pre = data[i][1]\n ans[i][2] = data[i][0]\nans = sorted(ans, key = lambda x:x[2])\nfor i in range(m):\n print(ans[i][0], ans[i][1])\n print("{:0=6}{:0=6}".format(ans[i][0],ans[i][1]))\n', 'n, m = list(map(int, input().split()))\ndata = []\nfor i in range(m):\n data.append([i + 1] + list(map(int, input().split())))\ndata = sorted(data, key = lambda x: (x[1], x[2]))\nprint(data)\nans = [[0,0,0,0,0,0], [0,0,0,0,0,0] for i in range(m)]\nprint(ans)\nfor i in range(m):\n', 'n, m = list(map(int, input().split()))\ndata = []\nfor i in range(m):\n data.append([i + 1] + list(map(int, input().split())))\n #data[0::] = cityNumber,\n \n #data[::0] = year\ndata = sorted(data, key = lambda x: (x[1], x[2]))\n#prefect => year\nans = [[0,0,0] for i in range(m)]\n#ans[::0] = city Number\n\n#ans[:0:] = ID\n\npre = data[0][1]\nnum = 0\nfor i in range(m):\n ans[i][0] = data[i][1] \n ans[i][2] = data[i][0] #cityNumber\n if pre == data[i][1]:\n num += 1\n else:\n num = 1\n ans[i][1] = num\n pre = data[i][1]\nans = sorted(ans, key = lambda x:x[2])\nfor i in range(m):\n print("{:0=6}{:0=6}".format(ans[i][0],ans[i][1]))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s230560753', 's241347315', 's548707468']
[40524.0, 3060.0, 39392.0]
[1117.0, 17.0, 1161.0]
[628, 274, 707]
p03221
u693007703
2,000
1,048,576
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.
['N, M = [int(i) for i in input().split()]\n\nPY = []\nPYd = {i:[] for i in range(1, N+1)}\n\nfor i in range(M):\n x, y = [int(i) for i in input().split()]\n PYd[x].append(y)\n PY.append((x,y))\n \nfor i in PYd.keys():\n PYd[i].sort()\n \nfor p,y in PY:\n str_p = str(p).zfill(6)\n index = str(bisect.bisect(PYd[p], y)).zfill(6)\n print(str_p+index)', 'import bisect\n\nN, M = [int(i) for i in input().split()]\n\nPY = []\nPYd = {i:[] for i in range(1, N+1)}\n\nfor i in range(M):\n x, y = [int(i) for i in input().split()]\n PYd[x].append(y)\n PY.append((x,y))\n \nfor i in PYd.keys():\n PYd[i].sort()\n \nfor p,y in PY:\n str_p = str(p).zfill(6)\n index = str(bisect.bisect(PYd[p], y)).zfill(6)\n print(str_p+index)']
['Runtime Error', 'Accepted']
['s596134559', 's484345232']
[37124.0, 38436.0]
[444.0, 700.0]
[358, 373]
p03221
u695079172
2,000
1,048,576
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.
["\n\nclass City:\n \n def __init__(self,id,y):\n self.id = id\n self.year = y\n\n\ndef main():\n n,m = map(int,input().split())\n pre_lst = [[] for _ in range(n)] \n city_tags = [0 for _ in range(m)] \n\n for i in range(m):\n p,y = map(int,input().split())\n pre_lst[p-1].append(City(i,y))\u3000\n\n for pre_num,pre in enumerate(pre_lst):\n if len(pre) <= 0:\n continue\n pre.sort(key = lambda x:x.year) \n\n counter = 0 \n for city in pre:\n city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)\n counter += 1\n for tag in city_tags:\n print(tag)\n\n\nif __name__ == '__main__':\n main()\n", "\n\nclass City:\n \n def __init__(self,id,y):\n self.id = id\n self.year = y\n\n\ndef main():\n n,m = map(int,input().split())\n pre_lst = [[] for _ in range(n)] \n city_tags = [0 for _ in range(m)] \n\n for i in range(m):\n p,y = map(int,input().split())\n pre_lst[p-1].append(City(i,y)) \n\n for pre_num,pre in enumerate(pre_lst):\n if len(pre) <= 0:\n continue\n pre.sort(key = lambda x:x.year) \n\n counter = 0 \n for city in pre:\n city_tags[city.id] = str(pre_num+1).zfill(6) + str(counter+1).zfill(6)\n counter += 1\n for tag in city_tags:\n print(tag)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s558975875', 's434259674']
[2940.0, 46216.0]
[17.0, 833.0]
[1182, 1180]
p03221
u695429668
2,000
1,048,576
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.
["N, M = map(int, input().split())\n\n_number = []\nP = []\nY = []\nyp = [[] for i in range(N+1)]\n_yp = []\n\nfor i in range(M):\n p, y = map(int, input().split())\n yp[p].append([y, i])\n\n# print(yp)\n\n_l_yp = len(yp)\n\nfor i in range(_l_yp):\n yp[i].sort()\n\n\nans_yp = [[] for i in range(M)]\n\nfor i in range(_l_yp):\n nga_yp = len(yp[i])\n\n for j in range(nga_yp):\n print(i, j)\n print(yp[i][j][1])\n ans_yp[yp[i][j][1]].append(i)\n ans_yp[yp[i][j][1]].append(j+1)\n\n\n__len = len(ans_yp)\n\nfor i in range(__len):\n buff = ''\n for d in range(2):\n ans = ''\n for j in range((6-len(str(ans_yp[i][d])))):\n ans += '0'\n\n buff += ans + str(ans_yp[i][d])\n\n print(buff)\n", "N, M = map(int, input().split())\n\n_number = []\nP = []\nY = []\nyp = [[] for i in range(N+1)]\n_yp = []\n\nfor i in range(M):\n p, y = map(int, input().split())\n yp[p].append([y, i])\n\n# print(yp)\n\n_l_yp = len(yp)\n\nfor i in range(_l_yp):\n yp[i].sort()\n\n\nans_yp = [[] for i in range(M)]\n\nfor i in range(_l_yp):\n nga_yp = len(yp[i])\n\n for j in range(nga_yp):\n # print(i, j)\n # print(yp[i][j][1])\n ans_yp[yp[i][j][1]].append(i)\n ans_yp[yp[i][j][1]].append(j+1)\n\n\n__len = len(ans_yp)\n\nfor i in range(__len):\n buff = ''\n for d in range(2):\n ans = ''\n for j in range((6-len(str(ans_yp[i][d])))):\n ans += '0'\n\n buff += ans + str(ans_yp[i][d])\n\n print(buff)\n"]
['Wrong Answer', 'Accepted']
['s431604419', 's084681544']
[48496.0, 46888.0]
[1349.0, 1124.0]
[718, 722]
p03221
u695811449
2,000
1,048,576
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.
['N,M=map(int,input().split())\nPY=[list(map(int,input().split())) for i in range(M)]\n\nPYI=[PY[i]+[i] for i in range(M)]\n\nPYI.sort(key=lambda x:x[1])\n\nNu=[1]*(N+1)\nANS=[None]*M\n\nfor p,y,i in PYI:\n ANS[i]=(p,Nu[p])\n Nu[p]+=1\n\nprint(ANS)\n\ndef numb(x,y):\n x=str(x)\n y=str(y)\n l=len(x)\n m=len(y)\n\n return (6-l)*"0"+x+(6-m)*"0"+y\n\nfor a,b in ANS:\n print(numb(a,b))', 'N,M=map(int,input().split())\nPY=[list(map(int,input().split())) for i in range(M)]\n\nPYI=[PY[i]+[i] for i in range(M)]\n\nPYI.sort(key=lambda x:x[1])\n\nNu=[1]*(N+1)\nANS=[None]*M\n\nfor p,y,i in PYI:\n ANS[i]=(p,Nu[p])\n Nu[p]+=1\n\n#print(ANS)\n\ndef numb(x,y):\n x=str(x)\n y=str(y)\n l=len(x)\n m=len(y)\n\n return (6-l)*"0"+x+(6-m)*"0"+y\n\nfor a,b in ANS:\n print(numb(a,b))']
['Wrong Answer', 'Accepted']
['s729545206', 's580625321']
[54744.0, 50268.0]
[775.0, 809.0]
[380, 381]
p03221
u703528810
2,000
1,048,576
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.
['N,M=map(int,input().split())\nP=[[x] for x in range(N)]\n\nfor _ in range(M):\n p,y=map(int,input().split())\n P[p-1].append(y)\ncode=[]\nfor i in range(N):\n temp=sorted(P[i][1:])\n for j in range(len(temp)):\n code.append(str(i+1).zfill(6)+str(j+1).zfill(6))\n\ncode.sort()\nfor c in code:\n print(c)', 'N,M=map(int,input().split())\n\nPre=[[] for _ in range(N)]\nfor i in range(M):\n p,y=map(int,input().split())\n Pre[p-1].append([y,i+1])\n\nID=[0 for _ in range(M)]\nfor j in range(N):\n Pre[j].sort()\n for k in range(len(Pre[j])):\n ID[Pre[j][k][1]-1]=str(j+1).zfill(6)+str(k+1).zfill(6)\n\nfor d in ID:\n print(d)']
['Wrong Answer', 'Accepted']
['s327850505', 's107672829']
[30660.0, 39108.0]
[670.0, 732.0]
[310, 323]
p03221
u704001626
2,000
1,048,576
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.
["# -*- coding: utf-8 -*-\na = int(input().split()[1])\nc = [int(input().split()[0]) for i in range(a)]\nimport collections\nc = collections.Counter(c)\nfor k,v in sorted(c.items()):\n for i in range(v):\n j = i+1\n print(f'{k:08}{j:08}')\n", "# -*- coding: utf-8 -*-\na = int(input().split()[1])\nc = [int(input().split()[0]) for i in range(a)]\nimport collections\nc = collections.Counter(c)\nfor k,v in sorted(c.items()):\n for i in range(v):\n print('{k:08}{i:08}'.format(k=k,i=i+1))\n", '# -*- coding: utf-8 -*-\nn,m = list(map(int,input().split()))\nd = [[i,tuple(map(int,input().split()))] for i,_ in enumerate(range(m))]\n#print(d)\n\nd.sort(key=lambda x:x[1][1])\np_cnt = [0] * (n+1)\nret_tuples = [0] * m \n\nfor i,v in enumerate(d):\n p = v[1][0]\n x = p_cnt[p]+1\n p_cnt[p]+=1\n ret_tuples[i] = (v[0],"{:0=6}{:0=6}".format(p,x))\n\nret_tuples.sort(key=lambda x:x[0])\nfor i in ret_tuples:\n print(i[1])']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s021830916', 's290148120', 's724556751']
[3188.0, 21508.0, 46852.0]
[18.0, 487.0, 756.0]
[246, 247, 461]
p03221
u706929073
2,000
1,048,576
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.
['(n, m) = map(int, input().split())\n\ncities = {}\nfor i in range(m):\n (i, j) = map(int, input().split())\n if not i in cities:\n cities[i] = []\n cities[i].append(j)\nprint(cities)\ncodes = []\nfor k, v in cities.items():\n v.sort()\n for i, j in enumerate(v):\n codes.append("{0:06d}".format(k) + "{0:06d}".format(i + 1))\nfor code in codes:\n print(code)', '(n, m) = map(int, input().split())\ncities = {}\nfor i in range(m):\n (pref, year) = map(int, input().split())\n if not pref in cities.keys():\n cities[pref] = []\n cities[pref].append((i, year))\n\n\ndef get_id(pref, index):\n return "{}{}".format(str(pref).zfill(6), str(index).zfill(6))\n\n\nids = []\nfor key, values in cities.items():\n values.sort(key=lambda x: x[1])\n for i, value in enumerate(values):\n ids.append((value[0], get_id(key, i + 1)))\nids.sort(key=lambda x: x[0])\nfor id in ids:\n print(id[1])\n']
['Wrong Answer', 'Accepted']
['s439783630', 's299884846']
[42048.0, 52924.0]
[685.0, 929.0]
[375, 532]
p03221
u707498674
2,000
1,048,576
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.
['N, M = map(int, input().split())\nP = [[] for i in range(N)]\nfor i in range(M):\n p, y = map(int, input().split())\n P[p-1].append(len(P[p-1])+1)\nfor i in range(len(P)):\n for j in range(len(P[i])):\n print("{:0=6}{:0=6}".format(i+1, P[i][j]))\n', 'N, M = map(int, input().split())\nP = [[] for i in range(N)]\ndata = []\nfor i in range(M):\n p, y = map(int, input().split())\n data.append([p, y, i])\n\ndata.sort(key=lambda x:x[1])\ndata.sort(key=lambda x:x[0])\n\ncity = 0\nfor i in range(M):\n if data[i][0] != city:\n city = data[i][0]\n num = 1\n data[i][1] = num\n num += 1\n \n\ndata.sort(key=lambda x:x[2])\nfor d in data:\n print("{:0=6}{:0=6}".format(d[0],d[1]))']
['Wrong Answer', 'Accepted']
['s166750269', 's946818620']
[16188.0, 31620.0]
[589.0, 809.0]
[255, 437]
p03221
u711295009
2,000
1,048,576
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.
['n, m = map(int, input().split())\nindex = 0\nlistForL = []\nlistForL2 = []\nwhile index < m:\n p, y = map(int, input().split())\n listForL.append([p, y])\n listForL2.append([p, y])\n index+=1\n\nlistForL2.sort()\nprint(listForL2)\nlistForId=[]\nindex2 =0\ncount = 0\nbefore=0\nwhile index2 < len(listForL2):\n if before!=listForL2[index2][0]:\n count=1\n before = listForL2[index2][0]\n else:\n count+=1\n mojiR=str(listForL2[index2][0])\n mojiL=str(count)\n index3=0\n while index3 < 6:\n if len(mojiR)< 6:\n mojiR="0"+mojiR\n elif len(mojiR)==6:\n break\n index3+=1\n index4=0\n while index4 < 6:\n if len(mojiL)< 6:\n mojiL="0"+mojiL\n elif len(mojiL)==6:\n break\n index4+=1\n index2+=1\n listForId.append(mojiR+mojiL)\n\nindex5=0\nwhile index5 < len(listForL):\n targetI = listForL2.index(listForL[index5])\n print(listForId[targetI])\n index5+=1\n ', 'n, m = map(int, input().split())\nindex = 0\nlistForL = []\nlistForL2 = []\nwhile index < m:\n p, y = map(int, input().split())\n listForL.append([p, y])\n listForL2.append([p, y, index])\n index+=1\n\nlistForL2.sort()\nlistForAns=[0]*m\nindex2 =0\ncount = 0\nbefore=0\nwhile index2 < len(listForL2):\n if before!=listForL2[index2][0]:\n count=1\n before = listForL2[index2][0]\n else:\n count+=1\n mojiR=str(listForL2[index2][0])\n mojiL=str(count)\n index3=0\n if len(mojiR)==1:\n mojiR="00000"+mojiR\n elif len(mojiR)==2:\n mojiR = "0000"+mojiR\n elif len(mojiR)==3:\n mojiR = "000"+mojiR\n elif len(mojiR)==4:\n mojiR = "00"+mojiR\n elif len(mojiR)==5:\n mojiR = "0"+mojiR\n if len(mojiL) == 1:\n mojiL = "00000"+mojiL\n elif len(mojiL) == 2:\n mojiL = "0000"+mojiL\n elif len(mojiL) == 3:\n mojiL = "000"+mojiL\n elif len(mojiL) == 4:\n mojiL = "00"+mojiL\n elif len(mojiL) == 5:\n mojiL = "0"+mojiL\n listForAns[listForL2[index2][2]]=mojiR+mojiL\n index2+=1\n\nfor ans in listForAns:\n print(ans)']
['Wrong Answer', 'Accepted']
['s292221017', 's910261367']
[40456.0, 41560.0]
[2106.0, 819.0]
[969, 1111]
p03221
u711539583
2,000
1,048,576
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.
["n, m = map(int, input().split())\ncs = []\nps = {}\nfor _ in range(m):\n p, y = map(int, input().split())\n cs.appenyd([y, p])\ncss = sorted(cs)\nfor c in css:\n if c[1] in ps:\n ps[c[1]].append(c[0])\n else:\n ps[c[1]] = [c[0]]\n[print('{:06}{:06}'.format(c[1], ps[c[1]].index(c[0])+1))for c in cs]\n\n \n \n \n", "n, m = map(int, input().split())\ncs = []\ncd = {}\nps = {}\nfor _ in range(m):\n p, y = map(int, input().split())\n cs.append([p, y])\n if p in ps:\n ps[p].append(y)\n else:\n ps[p] = [y]\n \nfor p in ps:\n v = sorted(ps[p])\n for i, y in enumerate(v):\n cd[y] = i + 1\n[print('{:06}{:06}'.format(c[0], cd[c[1]])) for c in cs]\n\n \n \n \n"]
['Runtime Error', 'Accepted']
['s572469209', 's401366646']
[3064.0, 48688.0]
[17.0, 719.0]
[307, 339]
p03221
u712975113
2,000
1,048,576
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.
["N,M=map(int,input().split())\nPY=[]\nfor i in range(M):\n PY.append(list(map(int,input().split()))+[i+1])\n PY.sort(key=lambda x:(x[0],x[1]))\nprint(PY)\nid=[]\nl=[]\nwhile len(PY)>0:\n p=PY[0][0]\n print(p)\n i=0\n print(i)\n while PY[i][0]==p:\n i+=1\n id.append('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(i)))+str(i))\n l.append(PY[i-1][2])\n print(i)\n if i+1>len(PY):\n break\n del PY[:i]\n print(PY)\n print(l)\n print(id)\nfor i in range(1,M+1):\n print(id[l.index(i)])", 'N,M = map(int,input().split())\nPY=[list(map(int,input().split()))+[0] for _ in range(M)]\nsort_PY=sorted(PY,key=lambda x:x[1])\nc={}\nfor i in range(M):\n p=sort_PY[i][0]\n if(p in c):\n c[p]+=1\n else:\n c[p]=1\n sort_PY[i][2]=c[p]\nfor p,y,z in PY:\n print(str(p).zfill(6)+str(z).zfill(6))']
['Wrong Answer', 'Accepted']
['s315968433', 's503011250']
[21824.0, 30096.0]
[2104.0, 633.0]
[532, 309]
p03221
u714225686
2,000
1,048,576
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.
['import math\nimport sys\nfrom itertools import accumulate\nfrom functools import reduce\nimport queue\nfrom fractions import gcd\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef combination_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef permutations_count(n, r):\n return math.factorial(n) // math.factorial(n - r)\n\nsys.setrecursionlimit(10000)\n\nmod = 1000000007\n\n\n\nif __name__ == "__main__":\n N, M = map(int, sys.stdin.readline().split())\n L = [list(map(int,list(sys.stdin.readline().split()))) for i in range(M)]\n sL = sorted(L, key=lambda x : x[0])\n\n d = {}\n for l in sL:\n if l[0] not in d:\n d[l[0]] = [l[1]]\n else:\n d[l[0]].append(l[1])\n\n for v in d.values():\n v.sort()\n\n for l in L:\n key = l[0]\n val = l[1]\n num = d[key].index(val) + 1\n print("{}{}".format(str(key).zfill(6),str(num).zfill(6)))\n', 'import math\nimport sys\nfrom itertools import accumulate\nfrom functools import reduce\nimport queue\nfrom fractions import gcd\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef combination_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef permutations_count(n, r):\n return math.factorial(n) // math.factorial(n - r)\n\nsys.setrecursionlimit(10000)\n\nmod = 1000000007\n\n\n\nif __name__ == "__main__":\n from time import time\n start = time()\n N, M = map(int, sys.stdin.readline().split())\n P = [0] * (N + 1)\n C = [0] * M\n\n for m in range(M):\n p, y = map(int, input().split())\n C[m] = [m, p, y, 0]\n C.sort(key=lambda x :x[2])\n\n for c in C:\n P[c[1]] += 1\n c[3] = P[c[1]]\n C.sort(key=lambda x :x[3])\n\n for c in C:\n print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))', 'import sys\n\nif __name__ == "__main__":\n N, M = map(int, sys.stdin.readline().split())\n P = [0] * (N + 1)\n C = [0] * M\n\n for m in range(M):\n p, y = map(int, input().split())\n C[m] = [m, p, y, 0]\n C.sort(key=lambda x :x[2])\n\n for c in C:\n P[c[1]] += 1\n c[3] = P[c[1]]\n C.sort(key=lambda x :x[0])\n\n for c in C:\n print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s350472284', 's847555064', 's702064572']
[44964.0, 32408.0, 29748.0]
[2105.0, 790.0, 709.0]
[1558, 1493, 428]
p03221
u718096172
2,000
1,048,576
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.
['N, M = [int(i) for i in input().split()]\npyList = [[int(i) for i in input().split()] for _ in range(M)]\npyList = sorted(pyList, key=lambda py: py[1])\n\ncityMap = {}\nfor py in pyList:\n if py[0] in cityMap.keys():\n cityMap[py[0]] += 1\n else:\n cityMap[py[0]] = 1\n\n prefCd = str(py[0]).zfill(6)\n cityCd = str(cityMap[py[0]]).zfill(3)\n print(prefCd + cityCd)\n', 'N, M = [int(i) for i in input().split()]\npyList = [[int(i) for i in input().split()] for _ in range(M)]\npyList = sorted(pyList, key=lambda py: py[1])\n\ncityMap = {}\nfor py in pyList:\n if py[0] in cityMap.keys():\n cityMap[py[0]] += 1\n else:\n cityMap[py[0]] = 1\n\n prefCd = str(py[0]).zfill(6)\n cityCd = str(cityMap[py[0]]).zfill(6)\n print(prefCd + cityCd)\n', 'N, M = [int(i) for i in input().split()]\nidx = 0\nipyList = []\nfor i in range(M):\n idx += 1\n ipy = [int(i) for i in input().split()]\n ipy.insert(0, idx)\n ipyList.append(ipy)\n\nipyList = sorted(ipyList, key=lambda ipy: ipy[2])\ncityMap = {}\nfor ipy in ipyList:\n if ipy[1] in cityMap.keys():\n cityMap[ipy[1]] += 1\n else:\n cityMap[ipy[1]] = 1\n ipy[2] = cityMap[ipy[1]]\n\nipyList = sorted(ipyList, key=lambda ipy: ipy[0])\nfor ipy in ipyList:\n print(str(ipy[1]).zfill(6) + str(ipy[2]).zfill(6))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s073946147', 's800138394', 's273831290']
[31368.0, 31620.0, 33624.0]
[600.0, 693.0, 715.0]
[382, 382, 523]
p03221
u721970149
2,000
1,048,576
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.
['import sys\ninput = sys.stdin.readline\nN, M = map(int,input().split())\nP = []\nfor i in range(M) :\n p, y = map(int,input().split())\n P.append([p, y, i])\n\nP.sort(key = lambda x: (x[0],x[1]))\nprint(P)\n\nans = [0 for i in range(M)]\ncount = 1\n\nfor i in range(M) :\n num = P[i][2]\n if i > 0 :\n if P[i][0] == P[i-1][0] :\n count += 1\n else :\n count = 1\n ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)\n\nfor t in ans :\n print(t)\n', 'import sys\ninput = sys.stdin.readline\nN, M = map(int,input().split())\nP = []\nfor i in range(M) :\n p, y = map(int,input().split())\n P.append([p, y, i])\n\nP.sort(key = lambda x: (x[0],x[1]))\n\nans = [0 for i in range(M)]\ncount = 1\n\nfor i in range(M) :\n num = P[i][2]\n if i > 0 :\n if P[i][0] == P[i-1][0] :\n count += 1\n else :\n count = 1\n ans[num] = str(P[i][0]).zfill(6) + str(count).zfill(6)\n\nfor t in ans :\n print(t)\n']
['Wrong Answer', 'Accepted']
['s171922160', 's998378038']
[38112.0, 32040.0]
[629.0, 524.0]
[478, 469]
p03221
u722535636
2,000
1,048,576
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.
['N, M = map(int, input().split())\nl = [dict() for i in range(N)]\nilist = [list(map(int, input().split())) for i in range(M)]\nfor i, y in ilist:\n l[i - 1][y] = 1\nl = [dict(sorted(l[i].items())) for i in range(N)]\nfor i in range(N):\n for j, k in enumerate(l[i].keys()):\n l[i][k] = "{:06}{:06}".format(i + 1, j + 1)\nfor n, y in ilist:\n print(int(l[n - 1][y]))\n', 'N, M = map(int, input().split())\nl = [dict() for i in range(N)]\nilist = [list(map(int, input().split())) for i in range(M)]\nfor i, y in ilist:\n l[i - 1][y] = 1\nl = [dict(sorted(l[i].items())) for i in range(N)]\nfor i in range(N):\n for j, k in enumerate(l[i].keys()):\n l[i][k] = "{:06}{:06}".format(i + 1, j + 1)\nfor n, y in ilist[::-1]:\n print(l[n - 1][y])\n', 'N, M = map(int, input().split())\nl=[list(map(int,input().split()))+[i] for i in range(M)]\nl=sorted(l,key=lambda x:x[0]*1000000000+x[1])\ncnt=0\nfor i,x in enumerate(l):\n if x[0]!=l[i-1][0]:cnt=0\n cnt+=1\n l[i][1]=cnt\nfor x in sorted(l,key=lambda x:x[2]):\n print("{:06}{:06}".format(x[0],x[1]))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s438016118', 's620375990', 's315909520']
[114016.0, 114016.0, 29724.0]
[890.0, 916.0, 766.0]
[372, 373, 302]
p03221
u725578977
2,000
1,048,576
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.
["# -*- coding: utf-8 -*-\nfrom collections import defaultdict\n\n\nn, m = map(int, input().split())\n\np, y = [], []\ndic = {}\nfor _ in range(m):\n pi, yi = map(int, input().split())\n dic[yi] = pi\n\nd = defaultdict(int)\n\nfor _, pi in sorted(dic.items()):\n d[pi] += 1\n print('{:0>6}{:0>6}'.format(pi, d[pi]))\n", "# -*- coding: utf-8 -*-\nfrom collections import defaultdict\n\n\nn, m = map(int, input().split())\n\ny = []\ndic = {}\nfor _ in range(m):\n pi, yi = map(int, input().split())\n y.append(yi)\n dic[yi] = pi\n\nd = defaultdict(int)\nid_dict = {}\n\nfor yi, pi in sorted(dic.items()):\n d[pi] += 1\n id_dict[yi] = '{:0>6}{:0>6}'.format(pi, d[pi])\n\nfor yi in y:\n print(id_dict[yi])\n"]
['Wrong Answer', 'Accepted']
['s768090973', 's661196284']
[36316.0, 49676.0]
[642.0, 661.0]
[310, 378]
p03221
u728615412
2,000
1,048,576
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.
['N,M = map(int,input().split())\nlst = [None]*M\npre_lst = []\nfor i in range(M):\n lst[i] = list(map(int,input().split()))\n lst[i].append(i)\nfor k in range(M):\n lst[k][0] = str(lst[k][0])\n lst[k][0] = lst[k][0].zfill(6)\nlst.sort(key = lambda x:x[0])\n\n', "N,M = map(int,input().split())\nlst = [None]*(M+1)\npre_count = 1\npre_current = ''\nlst[0] = ['000000',0,0]\nfor i in range(1,M+1):\n lst[i] = list(map(int,input().split()))\n lst[i].append(i)\nfor k in range(1,M+1):\n lst[k][0] = str(lst[k][0])\n lst[k][0] = lst[k][0].zfill(6)\nlst.sort(key = lambda x:x[1])\nlst.sort(key = lambda x:x[0])\nfor j in range(1,M+1):\n if lst[j][0] == lst[j-1][0]:\n pre_count += 1\n lst[j].append(str(pre_count).zfill(6))\n else:\n pre_count = 1\n lst[j].append(str(pre_count).zfill(6))\nlst.sort(key = lambda x:x[2])\nfor x in range(1,M+1):\n print(lst[x][0]+lst[x][3])"]
['Wrong Answer', 'Accepted']
['s883607680', 's396346672']
[37760.0, 43280.0]
[552.0, 912.0]
[251, 600]
p03221
u729133443
2,000
1,048,576
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.
["I=lambda:list(map(int,input().split()));n,m=I();l=[I()+[i]for i in range(M)];c=[0]*-~N;a=[0]*M\nfor p,y,i in sorted(l,key=lambda x:x[1]):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]\nfor t in a:print(t)", "I=lambda:list(map(int,input().split()[::-1]))\nm,n=I()\nc=[0]*-~n\na=[0]*m\nfor y,p,i in sorted(I()+[i]for i in range(m)):\n c[p]+=1\n a[i]='%06d%06d'%(p,c[p])\nprint('\\n'.join(a))"]
['Runtime Error', 'Accepted']
['s819473916', 's686008998']
[3064.0, 31172.0]
[17.0, 636.0]
[189, 175]
p03221
u736729525
2,000
1,048,576
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.
['N, M = [int(x) for x in input().split()]\n\nP, Y = [], []\n\nPx = [0] * (N+1)\nfor _ in range(M):\n p, y = [int(x) for x in input().split()]\n Px[p]+=1\n print("%06d%06d" % (p, Px[p]))\n\n', 'N, M = [int(x) for x in input().split()]\n\nPY = []\n\nPx = [0] * (N+1)\nfor i in range(M):\n p, y = [int(x) for x in input().split()]\n PY.append((i, p, y))\n\nPY.sort(key=lambda x:x[2])\nresult = [None]*M\nfor i, p, y in PY:\n Px[p]+=1\n result[i] = "%06d%06d" % (p, Px[p])\n\nfor x in result:\n print(x)\n\n# 2 3\n# 1 32\n# 2 63\n# 1 12\n\n# 000001000002\n# 000002000001\n# 000001000001\n']
['Wrong Answer', 'Accepted']
['s173431215', 's123031205']
[5108.0, 29796.0]
[969.0, 531.0]
[187, 380]
p03221
u740284863
2,000
1,048,576
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.
['n,m = map(int,input().split())\ncity = [[] for i in range(n)]\ndef f(s):\n s = str(s)\n t = 6 - len(s)\n s = "0"*t + s\n return s\nfor i in range(m):\n ken,year = map(int,input().split())\n city[ken-1].append(year)\nfor i in range(n):\n city[i].sort()\n for j in range(len(city[i])):\n ans = f(i+1) + f(j+1)\n print(ans)', 'n,m = map(int,input().split())\ncity = [[] for i in range(n)]\ndef f(s):\n s = str(s)\n t = 6 - len(s)\n s = "0"*t + s\n return s\nfor i in range(m):\n ken,year = map(int,input().split())\n city[ken-1].append([year,i])\nnewcity = []\nfor i in range(n):\n city[i].sort()\n for j in range(len(city[i])):\n newcity.append([city[i][j][1],f(i+1) + f(j+1)])\nnewcity.sort()\nfor i in range(m):\n print(newcity[i][1])\n']
['Wrong Answer', 'Accepted']
['s883704282', 's135217671']
[19376.0, 48580.0]
[610.0, 1090.0]
[345, 429]
p03221
u740767776
2,000
1,048,576
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.
['n,m=map(int,input().split())\ns = []\nr = []\nfor n in range(n):\n s.append(list(map(int,input().split())))\nfor i in range(n):\n rank = 1\n for j in range(n):\n if s[i][0] == s[j][0] and s[i][1] > s[j][1]:\n rank += 1\n prefString = str(s[i][0])\n rankString = str(rank)\n Number1st = "0" * (6-len(prefString)) + prefString \n Number2nd = "0" * (6-len(rankString)) + rankString\n print(Number1st+Number2nd)', 'n,m=map(int,input().split())\ns = []\nfor i in range(m):\n pref,year=map(int,input().split())\n s.append([pref,year,i])\ns.sort()\nrank = 1\nfor i in range(m):\n if s[i][0] != s[i-1][0]:\n rank = 1\n s[i][1]=rank\n rank += 1\ns.sort(key=lambda x: x[2]) \nfor i in range(m):\n print("0"*(6-len(str(s[i][0])))+str(s[i][0])+"0"*(6-len(str(s[i][1])))+str(s[i][1]))']
['Runtime Error', 'Accepted']
['s324247953', 's765224809']
[29360.0, 24744.0]
[2105.0, 783.0]
[435, 371]
p03221
u741397536
2,000
1,048,576
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.
['import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\nN, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append([P, Y])\n\nL = sorted(L)\n\nreset = 0\ncount = 0\nfor i in range(M):\n if L[i][0] != reset:\n reset = L[i][0]\n count = 1\n else:\n count += 1\n \n ans = str(reset).zfill(6) + str(count).zfill(6)\n print(ans)', 'import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\nN, M = map(int, input().split())\nL = []\nfor i in range(M):\n P, Y = map(int, input().split())\n L.append([P, Y, i])\n\nL = sorted(L)\n\nreset = 0\ncount = 0\nans = []\nfor i in range(M):\n if L[i][0] != reset:\n reset = L[i][0]\n count = 1\n else:\n count += 1\n \n ans.append([L[i][2], str(reset).zfill(6) + str(count).zfill(6)])\n\nans = sorted(ans)\n\nfor i in range(M):\n print(ans[i][1])']
['Wrong Answer', 'Accepted']
['s328460052', 's004705693']
[20976.0, 43956.0]
[464.0, 793.0]
[409, 483]
p03221
u745087332
2,000
1,048,576
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.
["# coding:utf-8\n\nimport sys\nfrom collections import Counter, defaultdict\n\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\n\nn, m = LI()\nYP = [[y, p] for p, y in (LI() for _ in range(m))]\n\nYP.sort()\n\nP = defaultdict(int)\nfor y, p in YP:\n P[p] += 1\n l1, l2 = len(str(p)), len(str(P[p]))\n id = (6 - l1) * '0' + str(p) + (6 - l2) * '0' + str(P[p])\n print(id)\n", "# coding:utf-8\n\nimport sys\nfrom collections import Counter, defaultdict\n\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\n\nn, m = LI()\nYP = [[y, p] for p, y in (LI() for _ in range(m))]\n\nYP2 = sorted(YP)\n\nP = defaultdict(int)\nans = {}\nfor y, p in YP2:\n P[p] += 1\n l1, l2 = len(str(p)), len(str(P[p]))\n id = '{:06d}{:06d}'.format(p, P[p])\n ans[y] = id\n\nfor y, p in YP:\n print(ans[y])\n"]
['Wrong Answer', 'Accepted']
['s109103515', 's387033260']
[30376.0, 42740.0]
[623.0, 637.0]
[534, 566]
p03221
u745561510
2,000
1,048,576
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.
['N, M = map(int,input().split())\nall_city = [list(map(int,input().split())) for i in range(M)]\n\ncity = {}\nfor i in all_city:\n if i[0] in city:\n city[i[0]].append(i[1])\n else:\n city[i[0]] = [i[1]]\n\nunder6 = {}\nfor i,k in city.items():\n city[i] = sorted(k)\n for j in range(len(k)):\n under6[k[j]] = j + 1\n\ndef change_Prefecture_code(prefecture):\n return str(prefecture).zfill(6)\n\ndef change_birth_code(birth_num):\n return str(birth_num).zfill(6)\n\nfor i in all_city:\n print(change_Prefecture_code(i[0]) + change_birth_code(under6[i[1]]))', 'N, M = map(int,input().split())\nall_city = [list(map(int,input().split())) for i in range(M)]\n\ncity = {}\nfor i in all_city:\n if i[0] in city:\n city[i[0]][city[i[0]].index(0)] = i[1]\n else:\n city[i[0]] = [0] * M\n city[i[0]][0] = i[1]\n\nprint(city)\n\nfor i,k in city.items():\n city[i] = sorted(k)\n\n\nfor i, k in city.items():\n for j in range(len(k)):\n if k[j] == 0:\n continue\n else:\n break\n\n\ndef change_Prefecture_code(prefecture):\n return str(prefecture).zfill(6)\n\ndef change_birth_code(birth_num):\n return str(birth_num).zfill(6)\nprint(city)\n\nfor i in all_city:\n print(change_Prefecture_code(i[0]) + change_birth_code(city[i[0]].index(i[1]) + 1))', 'N, M = map(int,input().split())\nall_city = [list(map(int,input().split())) for i in range(M)]\n\ncity = {}\nfor i in all_city:\n if i[0] in city:\n city[i[0]][city[i[0]].index(0)] = i[1]\n else:\n city[i[0]] = [0] * M\n city[i[0]][0] = i[1]\n\n\nfor i,k in city.items():\n city[i] = sorted(k)\n\n\nfor i, k in city.items():\n for j in range(len(k)):\n if k[j] == 0:\n continue\n else:\n break\n\n\ndef change_Prefecture_code(prefecture):\n return str(prefecture).zfill(6)\n\ndef change_birth_code(birth_num):\n return str(birth_num).zfill(6)\nprint(city)\n\nfor i in all_city:\n print(change_Prefecture_code(i[0]) + change_birth_code(city[i[0]].index(i[1]) + 1))', 'N, M = map(int,input().split())\nall_city = [list(map(int,input().split())) for i in range(M)]\n\ncity = {}\nfor i in all_city:\n if i[0] in city:\n city[i[0]][city[i[0]].index(0)] = i[1]\n else:\n city[i[0]] = [0] * M\n city[i[0]][0] = i[1]\n\n\nfor i,k in city.items():\n city[i] = sorted(k)\n\n\nfor i, k in city.items():\n for j in range(len(k)):\n if k[j] == 0:\n continue\n else:\n break\n\n\ndef change_Prefecture_code(prefecture):\n return str(prefecture).zfill(6)\n\ndef change_birth_code(birth_num):\n return str(birth_num).zfill(6)\n\nfor i in all_city:\n print(change_Prefecture_code(i[0]) + change_birth_code(city[i[0]].index(i[1]) + 1))', 'N, M = map(int,input().split())\nall_city = [list(map(int,input().split())) for i in range(M)]\n \ncity = {}\nfor i in all_city:\n if i[0] in city:\n city[i[0]].append(i[1])\n else:\n city[i[0]] = [i[1]]\n \nunder6 = {}\nfor i,k in city.items():\n city[i] = sorted(k)\n for j in range(len(city[i])):\n under6[city[i][j]] = j + 1\n\ndef change_Prefecture_code(prefecture):\n return str(prefecture).zfill(6)\n \ndef change_birth_code(birth_num):\n return str(birth_num).zfill(6)\n \nfor i in all_city:\n print(change_Prefecture_code(i[0]) + change_birth_code(under6[i[1]]))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s288225000', 's323536327', 's553447626', 's792844953', 's011152603']
[53408.0, 1970344.0, 1945384.0, 1952796.0, 53408.0]
[810.0, 2228.0, 2228.0, 2230.0, 766.0]
[574, 721, 709, 697, 590]
p03221
u747602774
2,000
1,048,576
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.
["N,M = map(int,input().split())\nPY = [list(map(int,input().split())) + [i] for i in range(M)]\n\nPY.sort()\nprint(PY)\n\npnow = PY[0][0]\nc = 1\n\nans = [-1 for i in range(M)]\n\nfor i in range(M):\n if pnow != PY[i][0]:\n c = 1\n pnow = PY[i][0]\n ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)\n c += 1\n\nprint('\\n'.join(ans))\n", 'import bisect\nN,M = map(int,input().split())\nPtoY = [[] for n in range(N)]\ncheck = []\nfor m in range(M):\n P,Y = map(int,input().split())\n PtoY[P-1].append(Y)\n check.append([P,Y])\nprint(check)\nfor n in range(N):\n PtoY[n].sort()\nprint(PtoY)\nfor m in range(M):\n p,y = check[m][0],check[m][1]\n a = bisect.bisect_left(PtoY[p-1],y)+1\n string = str(p).zfill(6) + str(a).zfill(6)\n print(string)\n', "N,M = map(int,input().split())\nPY = [list(map(int,input().split())) + [i] for i in range(M)]\n\nPY.sort()\n\npnow = PY[0][0]\nc = 1\n\nans = [-1 for i in range(M)]\n\nfor i in range(M):\n if pnow != PY[i][0]:\n c = 1\n pnow = PY[i][0]\n ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)\n c += 1\n\nprint('\\n'.join(ans))\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s070317778', 's189232937', 's815398729']
[38120.0, 38268.0, 38836.0]
[712.0, 792.0, 516.0]
[345, 411, 335]
p03221
u752767312
2,000
1,048,576
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.
['N,M = map(int,input().split())\nshi_lst = [list(map(int,input().split())) for i in range(M)]\nshi_sorted = sorted(shi_lst)\n#print(shi_lst)\n\n\ntmp = shi_sorted[0][0] \ncount = 0\nfor i in range(M):\n count += 1\n if tmp != shi_sorted[i][0]:\n count = 1\n tmp = shi_sorted[i][0]\n# ans.append( ("%06d"%tmp) + ("%06d"%count))\n print( ("%06d"%tmp) + ("%06d"%count))\n\n#print(ans)', 'N,M = map(int,input().split())\nshi_lst = [list(map(int,input().split())) for i in range(M)]\nshi_sorted = sorted(shi_lst)\n#print(shi_lst)\n\nans = {}\ntmp = shi_sorted[0][0] \ncount = 0\nfor i in range(M):\n count += 1\n if tmp != shi_sorted[i][0]:\n count = 1\n tmp = shi_sorted[i][0]\n ans[str(shi_sorted[i][1])] = ("%06d"%tmp) + ("%06d"%count) \n# ans.append( ("%06d"%tmp) + ("%06d"%count))\n# print( ("%06d"%tmp) + ("%06d"%count))\n\n#print(ans)\nfor i in range(M):\n print(ans[str(shi_lst[i][1])])']
['Wrong Answer', 'Accepted']
['s601848838', 's461981292']
[30344.0, 48612.0]
[674.0, 824.0]
[409, 523]
p03221
u757117214
2,000
1,048,576
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.
['N,M = map(int,input().split()) \ncity_info = [] \nPref_info = [[] for _ in range(N)] \nfor i in range(M):\n P,Y = map(int,input().split())\n city_info.append([P-1, Y])\n Pref_info[P - 1].append(Y)\nfor i in Pref_info:\n i.sort()\n \nprint("city_info = " + str(city_info))\nprint("Pref_info = " + str(Pref_info))\nfor p,y in city_info:\n x = Pref_info[p].index(y) + 1 \n print("{0:0>6}".format(p+1) + "{0:0>6}".format(x))', 'N,M = map(int,input().split()) \ncity_info = [] \nPref_info = [[] for _ in range(N)] \nfor i in range(M):\n P,Y = map(int,input().split())\n city_info.append([P-1, Y])\n Pref_info[P - 1].append(Y)\n \n#print("city_info = " + str(city_info))\n#print("Pref_info = " + str(Pref_info))\nfor p,y in city_info:\n x = Pref_info[p].index(y) + 1 \n print("{0:0>6}".format(p+1) + "{0:0>6}".format(x))', 'N,M = map(int,input().split()) \nPref_info = [[] for _ in range(N)] \nfor i in range(M):\n P,Y = map(int,input().split())\n Pref_info[P - 1].append([Y,i])\nans = [""]* M \nfor i in range(N): \n Pref_info[i].sort()\n for index, p in enumerate(Pref_info[i]):\n ans[p[1]] = "{0}{1}".format(str(i+1).zfill(6),str(index+1).zfill(6))\nfor i in ans:\n print(i)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s211902031', 's725661107', 's732603511']
[38260.0, 32748.0, 39096.0]
[2105.0, 2105.0, 742.0]
[604, 573, 364]