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
u759412327
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())\nC = sorted([list(map(int, input().split())) for m in range(M)])\nA = (N+1)*[0]\nD = {}\n\nfor p,y in C:\n A[p]+=1\n D[y]="%06d%06d" % (p,A[p])\n\nfor p,y in C:\n print(D[y])', 'N,M = map(int,input().split())\nC = sorted([list(map(int,input().split())) for m in range(M)])\nn = 1\n\nfor m in range(M-1):\n if C[m][0]==C[m+1][0]:\n C[m]+=[n]\n n+=1\n else:\n C[m]+=[n]\n n = 1\n\nC[-1]+=[n]\n\nfor m in range(M):\n print("{:06d}{:06d}".format(C[m][0],C[m][2]))', 'N,M = map(int, input().split())\nP = [list(map(int, input().split())) for m in range(M)]\nC = (N+1)*[0]\nD = {}\n\nfor p,y in sorted(P,key=lambda x: x[1]):\n C[p]+= 1\n D[y]="%06d%06d" % (p,C[p])\n\nfor p,y in P:\n print(D[y])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s474145661', 's678272588', 's398652147']
[42176.0, 30300.0, 42984.0]
[509.0, 530.0, 400.0]
[199, 281, 219]
p03221
u762420987
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 = [tuple(map(int, input().split())) for _ in range(M)]\nfrom copy import deepcopy\nPYsorted = sorted(deepcopy(PYlist), key=lambda x: x[0])\n\n\ndef zero_ume(num: int) -> str:\n return (6 - len(str(num))) * "0" + str(num)\n\n\nnow_ken = 0\nans_dict = {}\nfor p, y in PYsorted:\n if p != now_ken:\n now_num = 1\n now_ken = p\n else:\n now_num += 1\n ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)\n\nfor py in PYlist:\n print(ans_dict[py])\n', 'N, M = map(int, input().split())\nPYlist = [tuple(map(int, input().split())) for _ in range(M)]\nfrom copy import deepcopy\nPYsorted = sorted(deepcopy(PYlist), key=lambda x: x[1])\nprint(PYlist)\nprint(PYsorted)\n\n\ndef zero_ume(num: int) -> str:\n return (6 - len(str(num))) * "0" + str(num)\n\n\nnow_ken = 0\nans_dict = {}\nfor p, y in PYsorted:\n if p != now_ken:\n now_num = 1\n now_ken = p\n else:\n now_num += 1\n ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)\n\nfor py in PYlist:\n print(ans_dict[py])\n', 'N, M = map(int, input().split())\nPYlist = [tuple(map(int, input().split())) for _ in range(M)]\nfrom copy import deepcopy\nPYsorted = sorted(deepcopy(PYlist))\n\n\ndef zero_ume(num: int) -> str:\n return (6 - len(str(num))) * "0" + str(num)\n\n\nnow_ken = -1\nans_dict = {}\nnow_num = 0\nfor p, y in PYsorted:\n if p != now_ken:\n now_num = 0\n now_ken = p\n now_num += 1\n ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)\n\nfor py in PYlist:\n print(ans_dict[py])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s030649076', 's669921786', 's816729171']
[39212.0, 45256.0, 38320.0]
[1047.0, 1143.0, 1106.0]
[498, 528, 477]
p03221
u766684188
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=[]\nfor i in range(m):\n a=i\n b,c=map(int,input().split())\n city.append([a,b,c])\ncity=sorted(city,key=lambda x:(x[1],x[2]))\nprint(city)\ncity[0].append(1)\nfor i in range(1,m):\n if city[i][1]!=city[i-1][1]:\n city[i].append(1)\n else:\n city[i].append(city[i-1][3]+1)\nprint(city)\nfor i in range(m):\n city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))\ncity=sorted(city,key=lambda x:(x[0]))\nfor i in range(m):\n print(city[i][4])', 'n,m=map(int,input().split())\ncity=[]\nfor i in range(m):\n a=i\n b,c=map(int,input().split())\n city.append([a,b,c])\ncity=sorted(city,key=lambda x:(x[1],x[2]))\njudge=1\ncount=1\nfor i in range(m):\n if city[i][1]==judge:\n city[i].append(count)\n count+=1\n else:\n city[i].append(1)\n judge=city[i][1]\n count=2\nfor i in range(m):\n city[i].append(str(city[i][1]).zfill(6)+str(city[i][3]).zfill(6))\ncity=sorted(city,key=lambda x:x[0])\nfor i in range(m):\n print(city[i][4])']
['Wrong Answer', 'Accepted']
['s332619669', 's346052532']
[46832.0, 38272.0]
[1082.0, 891.0]
[503, 515]
p03221
u776495719
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 = list(map(int, input().split()))\n\ncities = {}\nprefs = []\n\nfor i in range(1, M + 1):\n p, y = list(map(int, input().split()))\n \n pref = {"city": p, "year": y}\n prefs.append(pref)\n\n if p not in cities:\n cities[p] = [pref]\n else:\n cities[p].append(pref)\nprint(cities)\nfor city in cities.values():\n city.sort(key=lambda p: p[\'year\'])\n for idx, pref in enumerate(city):\n pref[\'pref_id\'] = str(idx + 1).zfill(6)\n\n[print("%s%s" % (\n str(int(pref[\'city\'])).zfill(6), \n pref[\'pref_id\'])) for pref in prefs]\n', 'N, M = list(map(int, input().split()))\n\ncities = {}\nprefs = []\n\nfor i in range(1, M + 1):\n p, y = list(map(int, input().split()))\n \n pref = {"city": p, "year": y}\n prefs.append(pref)\n\n if p not in cities:\n cities[p] = [pref]\n else:\n cities[p].append(pref)\n\nfor city in cities.values():\n city.sort(key=lambda p: p[\'year\'])\n for idx, pref in enumerate(city):\n pref[\'pref_id\'] = str(idx + 1).zfill(6)\n\n[print("%s%s" % (\n str(int(pref[\'city\'])).zfill(6), \n pref[\'pref_id\'])) for pref in prefs]\n']
['Wrong Answer', 'Accepted']
['s661240741', 's125955732']
[71604.0, 63516.0]
[1026.0, 900.0]
[537, 509]
p03221
u779455925
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())\ndata=[list(map(int,input().split())) for i in range(M)]\ndata=sorted(data, key=lambda x: x[1])\nprepri=-1\ncount=0\nprintdata=[]\nfor i in data:\n if prepri!=i[0]:\n prepri=i[0]\n count=1\n else:\n count+=1\n printdata.append("0"*(6 - len(str(prepri))) + str(prepri) + "0"*(6 - len(str(count))) + str(count) )\nprintdata.reverse()\nfor i in printdata:\n print(i)\n', 'N,M=map(int,input().split())\ndata=[list(map(int,input().split())) for i in range(M)]\ndata=sorted(data, key=lambda x: x[1])\nprepri=-1\ncount=0\nprintdata=[]\nfor i in data:\n if prepri!=i[0]:\n prepri=i[0]\n count=1\n else:\n count+=1\n printdata.append("0"*(6 - len(str(prepri))) + str(prepri) + "0"*(6 - len(str(count))) + str(count) )\nfor i in printdata:\n print(i)\n', 'N,M=map(int,input().split())\ndata=[list(map(int,input().split()+[i])) for i in range(M)]\ndata=sorted(data,key=lambda x:x[1])\ndata=sorted(data,key=lambda x:x[0])\npreP=None\ncount=None\nprintdata=[]\nfor i in data:\n if preP==i[0]:\n count+=1\n else:\n preP=i[0]\n count=1\n printdata.append(["0"*(6-len(str(preP)))+str(preP)+"0"*(6-len(str(count)))+str(count),i[2]])\nprintdata=sorted(printdata,key=lambda x:x[1])\nfor i in printdata:\n print(i)\n', 'N,M=map(int,input().split())\ndata=[list(map(int,input().split()+[i])) for i in range(M)]\ndata=sorted(data,key=lambda x:x[1])\ndata=sorted(data,key=lambda x:x[0])\npreP=None\ncount=None\nprintdata=[]\nfor i in data:\n if preP==i[0]:\n count+=1\n else:\n preP=i[0]\n count=1\n printdata.append(["0"*(6-len(str(preP)))+str(preP)+"0"*(6-len(str(count)))+str(count),i[2]])\nprintdata=sorted(printdata,key=lambda x:x[1])\nfor i in printdata:\n print(i[0])\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s131439129', 's348316718', 's563761332', 's420539569']
[36080.0, 36072.0, 48776.0, 47704.0]
[628.0, 637.0, 1081.0, 1012.0]
[411, 391, 466, 469]
p03221
u780364430
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 = []\nd = {}\nfor n_ in range(n):\n d[n_ + 1] = []\nfor i in range(m):\n p_, y_ = map(int, input().split())\n p.append(p_)\n y.append(y_)\n d[p_].append(y_)\nfor i in d.keys():\n d[i] = np.argsort(d[i]) + 1\nid_list = []\nfor key in d:\n for n_ in d[key]:\n id_list.append('{:06d}{:06d}'.format(key, n_))\nid_list = sorted(id_list)\nfor id_ in id_list:\n print(id_)\n", "import numpy as np\nfrom bisect import bisect_right\nfrom time import time\nstart = time()\nn, m = map(int, input().split())\np = []\ny = []\nd = {i + 1: [] for i in range(n)}\n# n, m = 10**5, 10**5\n# p = [10**5]*m\n\nfor i in range(m):\n p_, y_ = map(int, input().split())\n # p_, y_ = p[i], y[i]\n p.append(p_)\n y.append(y_)\n d[p_].append(y_)\nfor i in d.keys():\n d[i] = sorted(d[i])\nfor i in range(m):\n # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))\n print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))\n\nprint(time() - start)\n", "from bisect import bisect_right\nn, m = map(int, input().split())\np = []\ny = []\nd = {i + 1: [] for i in range(n)}\nfor i in range(m):\n p_, y_ = map(int, input().split())\n p.append(p_)\n y.append(y_)\n d[p_].append(y_)\nfor i in d.keys():\n d[i] = sorted(d[i])\nfor i in range(m):\n print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s281195804', 's997241269', 's409821966']
[55780.0, 42360.0, 33512.0]
[2065.0, 826.0, 679.0]
[441, 597, 356]
p03221
u780962115
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.
['somelists=[]\n\nfor i in range(m):\n a,b=map(int,input().split())\n somelists.append([i,a,b])\n\nsomelists.sort(key=lambda x:(x[1],x[2]))\n\nprefs=1\nnumbers=0\n\nfor x in somelists:\n \n if x[1]==prefs:\n numbers+=1\n \n x.append(numbers)\n if x[1]!=prefs:\n prefs=x[1]\n numbers=1\n x.append(numbers)\n\nsomelists.sort(key=lambda x:x[0])\nfor _ in range(m):\n print(str(somelists[_][1]).zfill(6)+str(somelists[_][3]).zfill(6))\n', 'n,m=map(int,input().split())\nsomelists=[]\n\nfor i in range(m):\n a,b=map(int,input().split())\n somelists.append([i,a,b])\n\nsomelists.sort(key=lambda x:(x[1],x[2]))\n\nprefs=1\nnumbers=0\n\nfor x in somelists:\n \n if x[1]==prefs:\n numbers+=1\n \n x.append(numbers)\n if x[1]!=prefs:\n prefs=x[1]\n numbers=1\n x.append(numbers)\n\nsomelists.sort(key=lambda x:x[0])\nfor _ in range(m):\n print(str(somelists[_][1]).zfill(6)+str(somelists[_][3]).zfill(6))\n']
['Runtime Error', 'Accepted']
['s121434980', 's119871914']
[3064.0, 35504.0]
[18.0, 803.0]
[465, 494]
p03221
u785989355
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.
['\nfrom scipy.stats import rankdata\nN,M = list(map(int,input().split()))\n\nPY = []\nP_Y = [[] for i in range(N)]\n\np_count = [0 for i in range(N)]\n\nfor i in range(M):\n p,y = list(map(int,input().split()))\n P_Y[p-1].append([y,p_count[p-1]])\n p_count[p-1]+=1\n PY.append([p,y])\n \nimport numpy as np\n\nP_Y_arg = []\nfor i in range(N):\n P_Y_arg.append(rankdata(np.array(P_Y[i])))\n\n \np_count = [0 for i in range(N)]\n\nfor i in range(M):\n ps = str(1000000+PY[i][0])\n ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]]))\n p_count[PY[i][0]-1]+=1\n print(ps[1:]+ys[1:])\n ', 'from scipy.stats import rankdata\nN,M = list(map(int,input().split()))\n\nPY = []\nP_Y = [[] for i in range(N)]\n\np_count = [0 for i in range(N)]\n\nfor i in range(M):\n p,y = list(map(int,input().split()))\n P_Y[p-1].append([y,p_count[p-1]])\n p_count[p-1]+=1\n PY.append([p,y])\n \nimport numpy as np\n\nP_Y_arg = []\nfor i in range(N):\n P_Y_arg.append(rankdata(np.array(P_Y[i])))\n\n \np_count = [0 for i in range(N)]\n\nfor i in range(M):\n ps = str(1000000+PY[i][0])\n ys = str(1000000+P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]] + 1)\n p_count[PY[i][0]-1]+=1\n print(ps[1:]+ys[1:])\n ', 'N,M = list(map(int,input().split()))\n\nPY = []\nP_Y = [[] for i in range(N)]\n\np_count = [0 for i in range(N)]\n\nfor i in range(M):\n p,y = list(map(int,input().split()))\n P_Y[p-1].append(y)\n p_count[p-1]+=1\n PY.append([p,y])\n \nimport numpy as np\n\nP_Y_arg = []\nfor i in range(N):\n P_Y_arg.append(np.array(P_Y[i]).argsort().argsort())\n\n \np_count = [0 for i in range(N)]\n\nfor i in range(M):\n ps = str(1000000+PY[i][0])\n ys = str(1000000+int(P_Y_arg[PY[i][0]-1][p_count[PY[i][0]-1]])+1)\n p_count[PY[i][0]-1]+=1\n print(ps[1:]+ys[1:])\n \n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s613372567', 's684636218', 's745001679']
[89052.0, 87904.0, 59400.0]
[2113.0, 2115.0, 1247.0]
[599, 597, 568]
p03221
u787562674
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\ninputs = []\nsorted_inputs = {}\n\nfor _ in range(M):\n P, Y = map(int, input().split())\n inputs.append((P, Y))\n if sorted_inputs.get(P) is None:\n sorted_inputs[P] = [Y]\n else:\n sorted_inputs[P].append(Y)\n\nfor input in sorted_inputs:\n sorted_inputs[input].sort()\n\nfor input in inputs:\n first = str(input[0]).rjust(8, '0')\n latter = str(sorted_inputs[input[0]].index(input[1])+1).rjust(8, '0')\n print(first + latter)\n", "N, M = map(int, input().split())\n\nsorted_inputs = {}\nans = [None]*M\n\nfor i in range(M):\n P, Y = map(int, input().split())\n if sorted_inputs.get(P) is None:\n sorted_inputs[P] = [(Y, i)]\n else:\n sorted_inputs[P].append((Y, i))\n\nfor pref, l in sorted_inputs.items():\n l.sort() \n for j, (Y, i) in enumerate(l):\n first = str(pref).rjust(6, '0')\n latter = str(j+1).rjust(6, '0')\n ans[i] = first + latter\n\nfor item in ans:\n print(item)"]
['Wrong Answer', 'Accepted']
['s186876794', 's885736310']
[33856.0, 42924.0]
[2105.0, 700.0]
[484, 505]
p03221
u790905630
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 n, m = map(int, input().split())\n P_Y_list = sorted([input().split() for i in range(m)])\n\n tmp = P_Y_list[0][0]\n counter = 1\n for element_list in P_Y_list:\n if tmp != element_list[0]:\n counter = 1\n tmp = element_list[0]\n element_list[1] = str(counter)\n counter += 1\n\n id_list = list(map(lambda P_Y_tuple: int(P_Y_tuple[0] + P_Y_tuple[1].zfill(6)), P_Y_list))\n for id in id_list:\n print("%012d"%id)\n\nif __name__ == "__main__":\n main()', 'def main():\n n, m = map(int, input().split())\n P_Y_list = [input().split() for i in range(m)]\n\n sorted_P_Y_list = sorted(P_Y_list, key=lambda x:(int(x[0]), int(x[1])))\n correspond_sort_index_list = [P_Y_list.index(ele) for ele in sorted_P_Y_list]\n\n same_id = sorted_P_Y_list[0][0]\n counter = 1\n\n for element_list in sorted_P_Y_list:\n if same_id != element_list[0]:\n counter = 1\n same_id = element_list[0]\n\n element_list[1] = str(counter)\n counter += 1\n\n id_list = list(map(lambda sorted_P_Y_tuple: int(sorted_P_Y_tuple[0] + sorted_P_Y_tuple[1].zfill(6)), sorted_P_Y_list))\n for id in correspond_sort_index_list:\n print("%012d"%id_list[id])\n\nif __name__ == "__main__":\n main()', 'def main():\n n, m = map(int, input().split())\n P_Y_list = [input().split() for i in range(m)]\n\n sorted_P_Y_list = sorted(P_Y_list)\n correspond_sort_index_list = [P_Y_list.index(ele) for ele in sorted_P_Y_list]\n\n same_id = sorted_P_Y_list[0][0]\n counter = 1\n \n for element_list in sorted_P_Y_list:\n if same_id != element_list[0]:\n counter = 1\n same_id = element_list[0]\n\n element_list[1] = str(counter)\n counter += 1\n\n id_list = list(map(lambda sorted_P_Y_tuple: int(sorted_P_Y_tuple[0] + sorted_P_Y_tuple[1].zfill(6)), sorted_P_Y_list))\n for id in correspond_sort_index_list:\n print("%012d"%id_list[id])\n\nif __name__ == "__main__":\n main()', 'n, m = map(int, input().split())\nP_Y_list = [list(map(int, input().split()))+[i] for i in range(m)]\nsorted_P_Y_list = sorted(P_Y_list, key=lambda x:(x[0], x[1]))\n\nsame_id = sorted_P_Y_list[0][0]\ncounter = 1\n\nfor element_list in sorted_P_Y_list:\n if same_id != element_list[0]:\n counter = 1\n same_id = element_list[0]\n\n element_list[1] = str(counter)\n counter += 1\n\nsorted_P_Y_list.sort(key=lambda x:x[2])\n\nfor id in sorted_P_Y_list:\n print("%012d"%int(str(id[0]).zfill(6) + id[1].zfill(6)))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s344252483', 's526092808', 's708832809', 's302562832']
[44440.0, 48656.0, 35872.0, 35680.0]
[601.0, 2106.0, 2106.0, 810.0]
[520, 755, 722, 516]
p03221
u793460864
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 = [0]*M\nY = [0]*M\nfor i in range(M):\n P[i],Y[i] = map(int, input().split())\nYx = Y \nY.sort()\ncount = [1]*(N+1)\nans = [0]*M\nfor i in range(M):\n j = Yx.index(Y[i])\n ans[j] = str(P[j]).zfill(6) + str(count[P[j]]).zfill(6)\n count[P[j]] = count[P[j]] +1\n\nfor i in range (M):\n print(ans[i])', 'import numpy as np\nN , M = map(int, input().split())\nP = [0]*M\nY = [0]*M\nfor i in range(M):\n P[i],Y[i] = map(int, input().split())\n\nY_ = np.argsort(Y)\ncount = [1]*(N+1)\nans = [0]*M\nfor i in range(M):\n ans[Y_[i]] = str(P[Y_[i]]).zfill(6) + str(count[P[Y_[i]]]).zfill(6)\n count[P[Y_[i]]] = count[P[Y_[i]]] +1\n \nfor i in range (M):\n print(ans[i])']
['Wrong Answer', 'Accepted']
['s690171206', 's570599531']
[15268.0, 30888.0]
[2104.0, 731.0]
[337, 356]
p03221
u794910686
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()]\nPY=[[] for _ in range(N)]\npy=[]\n\nfor i in range(M):\n p,y=[int(i) for i in input().split()]\n py.append((p,y))\n PY[p-1].append(y)\n\nfor i in range(N):\n PY[i].sort()\n\nfor i in range(M):\n p,y=py.pop(0)\n #print(PY[p].index(y))\n p_zero=6-len(str(p))\n y_zero=6-len(str(PY[p].index(y)))\n print("0"*p_zero + str(p) + "0"*y_zero + str(PY[p].index(y)+1))\n', 'N,M=[int(i) for i in input().split()]\nPY=[[] for _ in range(N)]\n\nfor i in range(M):\n p,y=[int(i) for i in input().split()]\n PY[p-1].append((y,i))\n\nans=[None]*M\nfor j,py in enumerate(PY): \n py.sort()\n for k,(y,i) in enumerate(py):\n print(k,y,i) \n ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)\n\nprint(*ans,sep="\\n")', 'N,M=[int(i) for i in input().split()]\nPY=[[] for _ in range(N)]\npy=[]\n\nfor i in range(M):\n p,y=[int(i) for i in input().split()]\n PY[p-1].append((y,i))\n\nans=[None]*M\nfor j,py in enumerate(PY): \n py.sort()\n for k,(y,i) in enumerate(py):\n ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)\n\nprint(*ans,sep="\\n")']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s631146879', 's962248780', 's669842807']
[28256.0, 39376.0, 37536.0]
[438.0, 832.0, 649.0]
[408, 407, 336]
p03221
u797016134
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())\ncount = [0]*n\npy = []\n\nfor i in range(m):\n p,y = map(int, input().split())\n count[p-1] += 1\n py.append([p,y])\n\nli = sorted(py)\ncount = np.cumsum(count)\n\nfor i in range(m):\n num = li.index(py[i]) + 1\n pref = str(py[i][0])\n if py[i][0] == 1:\n print(pref.zfill(6) + str(num).zfill(6))\n else:\n print(pref.zfill(6) + str(num - count[i]).zfill(6))', 'n,m = map(int, input().split())\npy = []\nfor i in range(m):\n p,y = map(int, input().split())\n py.append((p,y,i))\npy.sort()\nli = [[0]*2 for i in range(m)]\ns = 0\nt = 0\nfor p,y,i in py:\n \n if s != p:\n s = p\n t = 1\n else:\n t += 1\n li[i][0] = s\n li[i][1] = t\nfor i in range(m):\n print(str(li[i][0]).zfill(6) + str(li[i][1]).zfill(6))']
['Runtime Error', 'Accepted']
['s318783362', 's772118768']
[32364.0, 35208.0]
[2110.0, 707.0]
[427, 455]
p03221
u797740860
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(" ")]\nps = []\npc = [0 for i in range(0, n + 1)]\n\nfor i in range(0, m):\n ps.append([i] + [int(i) for i in input().split(" ")] + [""])\n\nsorted(ps, key=lambda x: x[2])\n\nfor i in range(0, m):\n pc[ps[i][1]] += 1\n ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)\n\nsorted(ps, key=lambda x: x[0])\n\nfor i in range(0, m):\n print(ps[i][3])', 'n, m = [int(i) for i in input().split(" ")]\nps = []\npc = [0 for i in range(0, n + 1)]\n\nfor i in range(0, m):\n ps.append([i] + [int(i) for i in input().split(" ")] + [""])\n\nps = sorted(ps, key=lambda x: x[2])\n\nfor i in range(0, m):\n pc[ps[i][1]] += 1\n ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)\n\nps = sorted(ps, key=lambda x: x[0])\n\nfor i in range(0, m):\n print(ps[i])', 'n, m = [int(i) for i in input().split(" ")]\nps = []\npc = [0 for i in range(0, n + 1)]\n\nfor i in range(0, m):\n ps.append([i] + [int(i) for i in input().split(" ")] + [""])\n\nps = sorted(ps, key=lambda x: x[2])\n\nfor i in range(0, m):\n pc[ps[i][1]] += 1\n ps[i][3] = str(ps[i][1]).zfill(6) + str(pc[ps[i][1]]).zfill(6)\n\nps = sorted(ps, key=lambda x: x[0])\n\nfor i in range(0, m):\n print(ps[i][3])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s045701431', 's719222819', 's031493842']
[33032.0, 35740.0, 33800.0]
[637.0, 875.0, 772.0]
[392, 399, 402]
p03221
u798818115
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# Your code here!\nfrom operator import itemgetter\n\nN,M=map(int,input().split())\n\nl=[[-1]*3 for i in range(M)]\n\nfor i in range(M):\n p,y=map(int,input().split())\n l[i]=[i,10**10*p+y]\n\nl.sort(key=itemgetter(1))\n\npre_n=l[0][1]//10**6\ncount=1\nfor i in range(M):\n n=l[i][1]//10**6\n if n==pre_n:\n l[i][1]=n*10**6+count\n count+=1\n else:\n pre_n=n\n count=1\n l[i][1]=n*10**6+count\nl.sort()\n\nfor i in range(M):\n s=str(l[i][1])\n print("0"*(12-len(s))+s)\n \n ', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\nfrom operator import itemgetter\n\nN,M=map(int,input().split())\n\nl=[[-1]*3 for i in range(M)]\n\nfor i in range(M):\n p,y=map(int,input().split())\n l[i]=[i,10**10*p+y]\n\nl.sort(key=itemgetter(1))\n\npre_n=l[0][1]//10**10\ncount=0\nfor i in range(M):\n n=int(l[i][1]//(10**10))\n print(n,pre_n)\n if n==pre_n:\n count+=1\n l[i][1]=n*10**6+count\n \n else:\n pre_n=n\n count=1\n l[i][1]=n*10**6+count\nl.sort()\n\nfor i in range(M):\n s=str(l[i][1])\n print("0"*(12-len(s))+s)\n \n \n\n', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\nfrom operator import itemgetter\n\nN,M=map(int,input().split())\n\nl=[[-1]*3 for i in range(M)]\n\nfor i in range(M):\n p,y=map(int,input().split())\n l[i]=[i,10**10*p+y]\n\nl.sort(key=itemgetter(1))\n\npre_n=l[0][1]//10**10\ncount=0\nfor i in range(M):\n n=int(l[i][1]//(10**10))\n if n==pre_n:\n count+=1\n l[i][1]=n*10**6+count\n \n else:\n pre_n=n\n count=1\n l[i][1]=n*10**6+count\nl.sort()\n\nfor i in range(M):\n s=str(l[i][1])\n print("0"*(12-len(s))+s)\n \n \n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s138869658', 's721965388', 's582455220']
[22488.0, 26052.0, 25028.0]
[733.0, 876.0, 717.0]
[549, 622, 603]
p03221
u800780376
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\nclass ID:\n def __init__(self,p,y,i):\n self.p = p\n self.y = y\n self.i = i\n self.IDed = False\n self.ID1 = None\n self.ID2 = None\n\n def ID(self):\n for i in range(1,6):\n if self.ID1 < 10**i:\n self.ID1 = "0"*(6-i) + str(self.ID1)\n break\n for i in range(1,6):\n if int(self.ID2) < 10**i:\n self.ID2 = "0"*(6-i) + str(self.ID2)\n break\n \n return self.ID1 + self.ID2\n\ncities = []\nfor i in range(0,M):\n P,Y = map(int,input().split())\n cities.append(ID(P,Y,i))\n\nfor p in range(N+1,1,-1):\n pref = []\n for i in range(0,M):\n if not cities[i].IDed:\n if cities[i].p == p:\n pref.append([cities[i].y, cities[i].i])\n cities[i].IDed = True\n pref.sort()\n count = 1\n for i,j in pref:\n cities[j].ID2 = count\n count = count + 1\n cities[j].ID1 = p\n\nfor i in range(0,M):\n print(cities[i].ID())\n', 'N, M = map(int,input().split())\n\nclass ID:\n def __init__(self,p,y,i):\n self.p = p\n self.y = y\n self.i = i\n self.ID1 = None\n self.ID2 = None\n\n def ID(self):\n for i in range(1,7):\n if self.ID1 < 10**i:\n self.ID1 = "0"*(6-i) + str(self.ID1)\n break\n for i in range(1,7):\n if int(self.ID2) < 10**i:\n self.ID2 = "0"*(6-i) + str(self.ID2)\n break\n \n return self.ID1 + self.ID2\n\ncities = []\nfor i in range(0,M):\n P,Y = map(int,input().split())\n cities.append(ID(P,Y,i))\ncities.sort(key = lambda x: x.y)\ncounter = [-1]\n\nfor i in range(0,N):\n counter.append(1)\n\nfor c in cities:\n c.ID1 = c.p\n c.ID2 = counter[c.p]\n counter[c.p] = counter[c.p] + 1\n\ncities.sort(key = lambda x: x.i)\n\nfor i in range(0,M):\n print(cities[i].ID())\n']
['Runtime Error', 'Accepted']
['s102612982', 's098195058']
[54024.0, 55296.0]
[2110.0, 1317.0]
[1049, 887]
p03221
u805332733
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())\nbase = [[int(l) for l in input().split()] for i in range(M)]\nsort_target = sorted(base)\n \n \nprint(sort_target)\nprefecture_index = sort_target[0][0]\ni=0\nresult = []\nfor target in sort_target:\n i = i + 1 if prefecture_index == target[0] else 1\n prefecture_index = target[0]\n result.append([base.index(target), "{:0=6}{:0=6}".format(target[0], i)])\n\nsorted_result = sorted(result) \nfor result in sorted_result:\n print(result[1])', 'N, M = map(int, input().split())\nbase = []\nfor i in range(M):\n (a, b) = map(int, input().split())\n base.append((a, b, i))\nsorted_target = sorted(base) \n\nprefecture_index = sorted_target[0][0]\n\ni=0\nresult = {}\n\nfor target in sorted_target:\n if prefecture_index == target[0]:\n i+=1\n else:\n prefecture_index = target[0]\n i = 1\n result[target[2]] = [prefecture_index, i]\n\nfor i in range(M):\n print("{:0=6}{:0=6}".format(result[i][0], result[i][1]))\n']
['Wrong Answer', 'Accepted']
['s132838212', 's722717001']
[28360.0, 41488.0]
[2106.0, 741.0]
[463, 460]
p03221
u810356688
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\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m=map(int,input().split())\n A=[]\n for i in range(m):\n p,y=map(int,input().split())\n A.append((p,y,i))\n A.sort()\n cunt=0\n pre=0\n ans=[]\n for a in A:\n s1=str(a[0])\n if pre!=a[0]:\n cunt=1\n pre=a[0]\n s2=str(cunt)\n ans.append((i,s1.zfill(6)+s2.zfill(6)))\n cunt+=1\n ans.sort()\n for s in ans:\n print(s[1])\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m=map(int,input().split())\n A=[]\n for i in range(m):\n p,y=map(int,input().split())\n A.append((p,y))\n A.sort()\n print(A)\n cunt=0\n pre=0\n ans=[]\n for a in A:\n s1=str(a[0])\n if pre!=a[0]:\n cunt=1\n pre=a[0]\n s2=str(cunt)\n ans.append(s1.zfill(6)+s2.zfill(6))\n cunt+=1\n ans.sort()\n for s in ans:\n print(s)\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m=map(int,input().split())\n A=[]\n for i in range(m):\n p,y=map(int,input().split())\n A.append((p,y))\n A.sort()\n cunt=0\n pre=0\n ans=[]\n for a in A:\n s1=str(a[0])\n if pre!=a[0]:\n cunt=1\n pre=a[0]\n s2=str(cunt)\n ans.append(s1.zfill(6)+s2.zfill(6))\n cunt+=1\n ans.sort()\n for s in ans:\n print(s)\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m=map(int,input().split())\n A=[]\n for i in range(m):\n p,y=map(int,input().split())\n A.append((p,y,i))\n A.sort()\n cunt,pre,ans=0,0,[]\n for a in A:\n s1=str(a[0])\n if pre!=a[0]:\n cunt=1\n pre=a[0]\n s2=str(cunt)\n ans.append((a[2],s1.zfill(6)+s2.zfill(6)))\n cunt+=1\n ans.sort()\n for s in ans:\n print(s[1])\n\nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s024256472', 's204518431', 's949229222', 's326608332']
[35596.0, 27084.0, 25272.0, 35620.0]
[475.0, 491.0, 450.0, 560.0]
[519, 523, 510, 514]
p03221
u812576525
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()))\npy = [list(map(int,input().split())) + [i] for i in range(m)]\n\nfrom operator import itemgetter\npy = sorted(py,key=itemgetter(1),reverse = False)\npy = sorted(py,key=itemgetter(0),reverse = False)\n#print(py)\n\nB = []\npref = 0\ncity = 0\nfor i in range(m):\n if py[i][0] != pref:\n pref += 1\n city = 1\n B.append(['0000' + str(py[i][0]) + '0000' + str(city) , py[i][2]])\n else:\n city += 1\n B.append(['0000' + str(py[i][0]) + '0000' + str(city) , py[i][2]])\nB = sorted(B,key=itemgetter(1),reverse = False)\n\nfor i in range(m):\n print(B[i][0])", "N,M = list(map(int,input().split()))\nPY = [list(map(int,input().split())) + [i] for i in range(M)]\n\nfrom operator import itemgetter\nPY= sorted(PY,key=itemgetter(1),reverse = False)\nPY = sorted(PY,key=itemgetter(0),reverse = False)\n\nB= []\npre = 0\ncity = 0\nfor i in range(M):\n if pre != PY[i][0]:\n pre = PY[i][0]\n city = 1\n B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])\n else:\n city += 1\n B.append([str(pre).rjust(6, '0') + str(city).rjust(6, '0') ,PY[i][2]])\n\nB= sorted(B,key=itemgetter(1),reverse = False) \nfor i in range(M):\n print(B[i][0])"]
['Wrong Answer', 'Accepted']
['s023107258', 's926912835']
[44148.0, 43892.0]
[928.0, 946.0]
[612, 618]
p03221
u813098295
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\n\nN, M = map(int, input().split())\nps, ys = [], []\n\nv = [ [] for _ in range(N+1) ]\n\nfor i in range(M):\n p, y = map(int, input().split())\n ps += [p]; ys += [y];\n v[p].append(y)\n\nfor i in range(N):\n v[i+1].sort()\n\n\nprint (ps)\nprint (ys)\n\nprint (v)\n\nfor i in range(M):\n print("{:06d}".format(ps[i]), end="")\n print("{:06d}".format(v[ps[i]].index(ys[i])+1))\n', 'def index_bin(l, x):\n n = len(l)\n b = 0\n e = n\n while(b != e):\n if x > l[(b+e)//2]:\n b = (b+e)//2 + 1\n else:\n e = (b+e)//2\n return b\n\n\nN, M = map(int, input().split())\n\nP = []\nY = []\nPY = [[] for _ in range(M)]\n\n\nfor i in range(M):\n p, y = map(int, input().split())\n P.append(p)\n Y.append(y)\n PY[p-1].append(y)\n\nfor i in range(M):\n PY[i+1].sort()\n\nfor i in range(M):\n x = index_bin(PY[P[i]-1], Y[i]) + 1\n print("%06d%06d" % (P[i], x))\n', 'from bisect import bisect_left\n\nN, M = map(int, input().split())\nP, Y = [], []\nv = [[] for _ in range(N+1)]\n\nfor i in range(M):\n p, y = map(int, input().split())\n P += [p]\n Y += [y]\n v[p] += [y]\n\nfor i in range(N+1):\n v[i].sort()\n\nfor x, y in zip(P, Y):\n print ("%06d" % x, end = "")\n print ("%06d" % int(bisect_left(v[x], y) + 1))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s021900001', 's159607452', 's225579581']
[29052.0, 22656.0, 24172.0]
[2104.0, 452.0, 783.0]
[417, 507, 353]
p03221
u813102292
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())\nres = list([] for i in range(n))\np,y = [],[]\nfor i in range(m):\n tmp = list(int(i) for i in input().split())\n p.append(tmp[0])\n y.append(tmp[1])\n res[tmp[0]-1].append(tmp[1])\n\nfor i in range(n):\n res[i] = sorted(res[i])\n\nfor i in range(n):\n print("{0:06d}{1:06d}".format(p[i], res[p[i]-1].index(y[i])+1))\n', "N,M = map(int,input().split())\nsrc = [tuple(map(int,input().split())) for i in range(M)]\n\ncs = [[] for i in range(N+1)]\nfor i,(p,y) in enumerate(src):\n cs[p].append((y,i))\nfor cc in cs:\n cc.sort()\n\nans = [None] * M\nfor p in range(len(cs)):\n for i,(_,j) in enumerate(cs[p]):\n s = str(p).zfill(6) + str(i+1).zfill(6)\n ans[j] = s\nprint(*ans, sep='\\n')\n"]
['Runtime Error', 'Accepted']
['s564092835', 's048305692']
[30208.0, 47772.0]
[2105.0, 707.0]
[363, 372]
p03221
u814781830
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\nN, M = map(int, input().split())\nPY = [list(map(int, input().split())) for i in range(M)]\nPY.sort(key=lambda x: x[1])\npydict = defaultdict(lambda: 0)\n\nfor i in PY:\n pydict[i[0]] += 1\n print(["{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))])', 'from collections import defaultdict\nN, M = map(int, input().split())\nPY = [list(map(int, input().split())) for i in range(M)]\nPY.sort(key=lambda x: x[1])\npydict = defaultdict(lambda: 0)\n\nfor i in PY:\n pydict[i[0]] += 1\n print("{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0])))', 'from collections import defaultdict\nN, M = map(int, input().split())\nPY = [list(map(int, input().split())) for i in range(M)]\nPY.sort(key=lambda x: x[1])\npydict = defaultdict(lambda: 0)\n\nfor i in PY:\n pydict[i[0]] += 1\n print(["{:0=10}".format(i[0]), "{:0=10}".format(pydict.get(i[0]))])', 'from collections import defaultdict\nN, M = map(int, input().split())\npy = [list(map(int, input().split())) for i in range(M)]\nPY = sorted(py, key=lambda x: x[1])\npydict = defaultdict(lambda: 0)\nans = {}\nfor i in PY:\n pydict[i[0]] += 1\n ans[str(i[0]) + str(i[1])] = "{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))\n\nfor i in py:\n print(ans.get(str(i[0]) + str(i[1])))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s051008933', 's707509054', 's982161071', 's087600262']
[38388.0, 38108.0, 39412.0, 56908.0]
[769.0, 696.0, 781.0, 851.0]
[292, 290, 293, 385]
p03221
u815666840
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 = []\npyy = []\n\nnpy = []\n\nfor i in range(m):\n\n pyy=list(map(int,input().split()))\n pyy.append(i)\n py.append(pyy)\n\nprint(py)\npy.sort(key=itemgetter(0,1))\n\nprint(py)\n\nnum = 1\n\nnpy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])\n\n\nfor i in range(m-1):\n if py[i+1][0] == py[i][0]:\n num = num + 1\n npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])\n else:\n num = 1\n npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])\n\nnpy.sort(key=itemgetter(1))\n\nfor j in range(m):\n print(npy[j][0])\n', 'from operator import itemgetter\n\nn,m = map(int,input().split())\npy = []\npyy = []\n\nnpy = []\n\nfor i in range(m):\n\n pyy=list(map(int,input().split()))\n pyy.append(i)\n py.append(pyy)\n\npy.sort(key=itemgetter(0,1))\n\n\nnum = 1\n\nnpy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])\n\n\nfor i in range(m-1):\n if py[i+1][0] == py[i][0]:\n num = num + 1\n npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])\n else:\n num = 1\n npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])\n\nnpy.sort(key=itemgetter(1))\n\nfor j in range(m):\n print(npy[j][0])\n']
['Wrong Answer', 'Accepted']
['s278607637', 's817640240']
[52756.0, 47392.0]
[1166.0, 977.0]
[631, 611]
p03221
u818283165
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 p,y = map(int,input().split())\n py[i] = (p,y)\nans = sorted(py.items(),key=lambda x:x[1])\n#print(ans[0][1][1])\ncount = 1\nnumber = []\nnumber.append(count)\n#print(ans)\nfor i in range(1,m):\n if ans[i][1][0] == ans[i-1][1][0]:\n count += 1\n else:\n count = 1\n number.append(count)\n#print(number)\n\nfor i in range(m):\n a = "{0:06d}".format(ans[i][1][0])\n b = "{0:06d}".format(number[i])\n print(a,end="")\n print(b)', 'n,m = map(int,input().split())\npy = {}\nfor i in range(m):\n p,y = map(int,input().split())\n py[i] = [p,y]\nans = sorted(py.items(),key=lambda x:x[1])\n#print(ans)\n#print(ans[0][1])\ncount = 1\nans[0][1].append(count)\n#print(ans)\nfor i in range(1,m):\n if ans[i][1][0] == ans[i-1][1][0]:\n count += 1\n else:\n count = 1\n ans[i][1].append(count)\n#print(number)\nans = sorted(ans)\n#print(ans)\nfor i in range(m):\n a = "{0:06d}".format(ans[i][1][0])\n b = "{0:06d}".format(ans[i][1][2])\n print(a,end="")\n print(b)']
['Wrong Answer', 'Accepted']
['s989357752', 's323561839']
[38236.0, 44468.0]
[827.0, 984.0]
[504, 539]
p03221
u820047642
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=[[0,0]]\nans=[]\nfor _ in range(M):\n PY.append(list(map(int,input().split())))\nPY.sort(key=lambda x:(x[0],x[1]))\n\nfor i in range(M):\n number=""\n if PY[i+1][0]!=PY[i][0]:\n x=1\n else:\n x+=1\n number+=str(PY[i+1][0]).zfill(6)\n number+=str(x).zfill(6)\n ans.append(number)\n\nfor i in ans:\n print(i)', 'N,M=map(int,input().split())\nPY=[[0,0]]\nans=[]\nfor m in range(M):\n L=list(map(int,input().split()))\n L.append(m+1)\n PY.append(L)\nPY.sort(key=lambda x:(x[0],x[1]))\n\nfor i in range(M):\n number=""\n if PY[i+1][0]!=PY[i][0]:\n x=1\n else:\n x+=1\n number+=str(PY[i+1][0]).zfill(6)\n number+=str(x).zfill(6)\n ans.append([number,PY[i+1][2]])\n\nans.sort(key=lambda x:x[1])\n\nfor i in ans:\n print(i[0])\n']
['Wrong Answer', 'Accepted']
['s560920661', 's830103553']
[36604.0, 45608.0]
[722.0, 949.0]
[359, 431]
p03221
u823458368
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 = []\ns = '000000'\nfor i in range(m):\n p, y = map(int, input().split())\n py.append([p, y, i])\npy.sort(key=lambda py:(py[0],py[1]))\n\npy[0].append(1)\nfor i in range(m-1):\n a = 1\n if py[i][0] == py[i+1][0]:\n py[i+1].append(py[i][3]+1)\n else:\n py[i+1].append(1)\n \npy.sort(key=lambda py:(py[2]))\n\nfor j in range(len(py)):\n print((s+str(py[j][0]))[-5:]+(s+str(py[j][3]))[-5:])", "n, m = map(int, input().split())\npy = []\ns = '000000'\nfor i in range(m):\n p, y = map(int, input().split())\n py.append([p, y, i])\npy.sort(key=lambda py:(py[0],py[1]))\n\npy[0].append(1)\nfor i in range(m-1):\n a = 1\n if py[i][0] == py[i+1][0]:\n py[i+1].append(py[i][3]+1)\n else:\n py[i+1].append(1)\n \npy.sort(key=lambda py:(py[2]))\n\nfor j in range(len(py)):\n print((s+str(py[j][0]))[-6:]+(s+str(py[j][3]))[-6:])"]
['Wrong Answer', 'Accepted']
['s504975443', 's157391422']
[35488.0, 35480.0]
[795.0, 805.0]
[444, 444]
p03221
u825027400
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\n\nif __name__ == "__main__":\n N, M = map(int, input().split())\n city_list = []\n pref_dec = {}\n for m in range(M):\n p, y = map(int, input().split())\n city_list.append((p, y))\n if p not in pref_dec:\n pref_dec[p] = []\n pref_dec[p].append(y)\n\n for p in pref_dec.keys():\n pref_dec[p].sort()\n\n print(pref_dec)\n for m in range(M):\n p_id = city_list[m][0]\n y_id = pref_dec[p_id].index(city_list[m][1]) + 1\n print(str(p_id).zfill(6) + str(y_id).zfill(6))\n', '#coding:utf-8\n\n\n\nif __name__ == "__main__":\n N, M = map(int, input().split())\n city_list = []\n for i in range(M):\n p, y = map(int, input().split())\n city_list.append([i, p, y])\n\n city_count = {}\n order_dic = {}\n for i, p, y in sorted(city_list, key = lambda x: x[2]):\n if not p in city_count:\n city_count[p] = 0\n city_count[p] += 1\n order_dic[i, p] = city_count[p]\n\n for i, p, y in city_list:\n print("{:06}{:06}".format(p, order_dic[i,p]))\n']
['Wrong Answer', 'Accepted']
['s926946247', 's118396915']
[41028.0, 44492.0]
[2105.0, 715.0]
[548, 583]
p03221
u826263061
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"""\nCreated on Sun Nov 4 18:54:20 2018\nABC113C\n@author: maezawa\n"""\n\nn, m = list(map(int, input().split()))\np = [0]\ny = [0]\nfor i in range(m):\n pi, yi = list(map(int, input().split()))\n p.append(pi)\n y.append(yi)\n\n#print(p)\n#print(y)\n \ncityn = [\'\']*m\n\nps = [[] for _ in range(n+1)]\nfor i in range(1,m+1):\n ps[p[i]].append(i)\n \nfor j in range(1,n+1):\n ps[j].sort(key = lambda x: y[x])\n for i, k in enumerate(ps[j]):\n left = \'000000\'+ str(j)\n right = \'000000\' + str(i+1)\n cityn[k-1] = left[len(left)-5:] + right[len(right)-5:]\n\nfor i in range(m):\n print(cityn[i])\n ', ' # -*- coding: utf-8 -*-\n"""\nCreated on Sun Nov 4 18:54:20 2018\nABC113C\n@author: maezawa\n"""\n\nn, m = list(map(int, input().split()))\np = [0]\ny = [0]\nfor i in range(m):\n pi, yi = list(map(int, input().split()))\n p.append(pi)\n y.append(yi)\n\n#print(p)\n#print(y)\n \ncityn = [\'\']*m\n\nps = [[] for _ in range(n+1)]\nfor i in range(1,m+1):\n ps[p[i]].append(i)\n \nfor j in range(1,n+1):\n ps[j].sort(key = lambda x: y[x])\n for i, k in enumerate(ps[j]):\n left = \'000000\'+ str(j)\n right = \'000000\' + str(i+1)\n cityn[k-1] = left[len(left)-5:] + right[len(right)-5:]\n\nfor i in range(m):\n print(cityn[i])\n ', ' # -*- coding: utf-8 -*-\n"""\nCreated on Sun Nov 4 18:54:20 2018\nABC113C\n@author: maezawa\n"""\n\nn, m = list(map(int, input().split()))\np = [0]\ny = [0]\nfor i in range(m):\n pi, yi = list(map(int, input().split()))\n p.append(pi)\n y.append(yi)\n\n#print(p)\n#print(y)\n \ncityn = [\'\']*m\n\nps = [[] for _ in range(n+1)]\nfor i in range(1,m+1):\n ps[p[i]].append(i)\n \nfor j in range(1,n+1):\n ps[j].sort(key = lambda x: y[x])\n for i, k in enumerate(ps[j]):\n left = \'000000\'+ str(j)\n right = \'000000\' + str(i+1)\n cityn[k-1] = left[len(left)-5:] + right[len(right)-5:]\n\nfor i in range(m):\n print(cityn[i])\n ', '# -*- coding: utf-8 -*-\n"""\nCreated on Sun Nov 4 18:54:20 2018\nABC113C\n@author: maezawa\n"""\n\nn, m = list(map(int, input().split()))\np = [0]\ny = [0]\nfor i in range(m):\n pi, yi = list(map(int, input().split()))\n p.append(pi)\n y.append(yi)\n\n#print(p)\n#print(y)\n \ncityn = [\'\']*m\n\nps = [[] for _ in range(n+1)]\nfor i in range(1,m+1):\n ps[p[i]].append(i)\n \nfor j in range(1,n+1):\n ps[j].sort(key = lambda x: y[x])\n for i, k in enumerate(ps[j]):\n left = \'000000\'+ str(j)\n right = \'000000\' + str(i+1)\n cityn[k-1] = left[len(left)-6:] + right[len(right)-6:]\n\nfor i in range(m):\n print(cityn[i])\n ']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s629733805', 's724785732', 's878896969', 's084939464']
[34192.0, 34228.0, 34228.0, 34332.0]
[790.0, 785.0, 770.0, 834.0]
[640, 640, 640, 639]
p03221
u826929627
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\nPY = []\nfor _ in range(M):\n py = list(map(int,input().split()))\n PY.append(py)\n\nPY.sort()\ncnt_pref = {}\nfor py in PY:\n p,y = py[0],py[1]\n if (p in cnt_pref):\n cnt_pref[p] += 1\n else:\n cnt_pref[p] = 1\n out = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)\n print(out)', "from operator import itemgetter\n\nN, M = map(int, input().split())\nPY = []\n\nfor i in range(M):\n PY.append([i, list(map(int,input().split())), 'x'])\n\nPY.sort(key=itemgetter(1,2))\ncnt_pref = {}\n\nfor i in range(M): \n p, y = PY[i][1][0], PY[i][1][1]\n if (p in cnt_pref):\n cnt_pref[p] += 1\n else:\n cnt_pref[p] = 1\n PY[i][2] = str(p).zfill(6) + str(cnt_pref[p]).zfill(6)\n\nPY.sort(key=itemgetter(0))\nfor i in PY:\n print(i[2])"]
['Wrong Answer', 'Accepted']
['s622883171', 's115639648']
[37728.0, 53088.0]
[731.0, 1102.0]
[309, 430]
p03221
u836737505
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\nfrom collections import defaultdict\nn,m = map(int,input().split())\np = [list(map(int, input().split())) for _ in range(m)]\n\na = defaultdict(list)\nfor x,y in sorted(p):\n a[x].append(y)\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("{0:06d}{0:06d}".format(x,z))', 'import bisect\nfrom collections import defaultdict\nn,m = map(int,input().split())\np = [list(map(int, input().split())) for _ in range(m)]\n \na = defaultdict(list)\nfor x,y in sorted(p):\n a[x].append(y)\nfor x,y in p:\n \n z=bisect.bisect(a[x],y)\n print("{0:06d}{1:06d}".format(x,z))']
['Wrong Answer', 'Accepted']
['s696799229', 's635994521']
[43316.0, 43316.0]
[735.0, 772.0]
[282, 288]
p03221
u842964692
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.
['#ABC113_C\n\nN,M=map(int,input().split())\nPYi=[]\nfor i in range(M):\n p,y=map(int,input().split())\n PYi.append([p,y,i])\n\nPYi.sort()\n\nprep=PYi[0][0]\ncc=1#city code\nPYi[0][1]=cc\nfor j in range(1,M):\n p=PYi[j][0]\n if prep==p:\n cc+=1\n else:\n cc=1\n PYi[j][1]=cc\n prep=p\n \nPYi.sort(key=lambda x:x[2])\n\ndef padding(A):\n A=str(A)\n while len(A)<6:\n A=str(0)+A\n return A\n\nfor i in range(M):\n print(padding(PYi[i][0]),padding(PYi[i][1]))', '#ABC113_C\n\nN,M=map(int,input().split())\nPYi=[]\nfor i in range(M):\n p,y=map(int,input().split())\n PYi.append([p,y,i])\n\nPYi.sort()\n\nprep=PYi[0][0]\ncc=1#city code\nPYi[0][1]=cc\nfor j in range(1,M):\n p=PYi[j][0]\n if prep==p:\n cc+=1\n else:\n cc=1\n PYi[j][1]=cc\n prep=p\n \nPYi.sort(key=lambda x:x[2])\n\ndef padding(A):\n A=str(A)\n while len(A)<6:\n A=str(0)+A\n return A\n\nfor i in range(M):\n ansi=padding(PYi[i][0])+padding(PYi[i][1])\n print(ansi)']
['Wrong Answer', 'Accepted']
['s407053780', 's675384536']
[24740.0, 24732.0]
[880.0, 1113.0]
[484, 498]
p03221
u844005364
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())\np = [list(map(int, input().split()+[i])) for i in range(m)]\n\np.sort()\ncnt = 1\npre = -1\n\nfor city in p:\n if city[0] == pre:\n cnt = cnt + 1\n else:\n pre = city[0]\n\n city.append("{:0>6}{:0>6}".format(city[0], cnt))\n\np.sort(key = lambda x: x[2])\n\nfor city in p:\n print(city[3])', '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)\np.sort()\nfor x,y in p:\n a[x]+=[y]\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', 'import sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\nn, m = map(int, input().split())\n\npre = [[] for _ in range(n)]\np = []\n\nfor i in range(m):\n p.append(list(map(int, input().split())))\n pre[p[i][0] - 1].append(p[i][1])\n\nfor i in range(m):\n pref = "{:0>6}".format(p[i][0])\n\n years = pre[p[i][0] - 1]\n years.sort()\n\n y = years.index(p[i][1]) + 1\n year = "{:0>6}".format(y)\n print(pref + year)\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', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s430739153', 's700906817', 's962705343', 's341291746']
[38808.0, 40244.0, 3064.0, 41012.0]
[594.0, 710.0, 18.0, 729.0]
[370, 256, 457, 255]
p03221
u844789719
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(_) for _ in input().split()]\nPN = [[] for _ in range(M)]\nY = [[] for _ in range(N)]\nP = [0 for _ in range(N)]\nfor i in range(M):\n p, y = [int(_) - 1 for _ in input().split()]\n PN[i] = [p, P[p]]\n Y[p].append(y)\n P[p] += 1\nY_rank = [np.argsort(_) for _ in Y]\nprint(PN)\nprint(Y)\nprint(Y_rank)\nfor i in range(M):\n print(str(PN[i][0] + 1).zfill(6) + str(Y_rank[PN[i][0]][PN[i][1]] + 1).zfill(6))\n', 'from scipy.stats import rankdata\nN, M = [int(_) for _ in input().split()]\nP = [M for _ in range(M)]\nPY = [[100000000 for _ in range(M)] for _ in range(N)]\nfor i in range(M):\n p, y = [int(_) - 1 for _ in input().split()]\n P[i] = p\n PY[p][i] = y\nPY2 = [[M for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n PY2[i] = [int(_) for _ in rankdata(PY[i])]\nprint(P)\nprint(PY)\nprint(PY2)\nfor i in range(M):\n print(str(P[i] + 1).zfill(6) + str(PY2[P[i]][i]).zfill(6))', 'from scipy.stats import rankdata\nN, M = [int(_) for _ in input().split()]\nP = [M for _ in range(M)]\nPY = [[100000000 for _ in range(M)] for _ in range(N)]\nfor i in range(M):\n p, y = [int(_) - 1 for _ in input().split()]\n P[i] = p\n PY[p][i] = y\nPY2 = [[M for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n PY2[i] = [int(_) for _ in rankdata(PY[i])]\nprint(P)\nprint(PY)\nprint(PY2)\nfor i in range(M):\n print(str(P[i] + 1).zfill(6) + str(PY2[P[i]][i]).zfill(6))', 'N, M = [int(_) for _ in input().split()]\nPY = [[int(_) for _ in input().split()] for _ in range(M)]\nPYI = sorted([PY[i] + [i] for i in range(M)], key=lambda xs:xs[1])\ncount_p = {}\nans = [None] * M\nfor p, y, i in PYI:\n count_p[p] = count_p.get(p, 0) + 1\n ans[i] = [p, count_p[p]]\n[print(str(p).zfill(6)+str(x).zfill(6)) for p, x in ans]\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s415886620', 's960266077', 's997887617', 's722810160']
[68232.0, 407272.0, 418448.0, 53104.0]
[2111.0, 2134.0, 2135.0, 873.0]
[437, 478, 478, 342]
p03221
u846226907
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 copy\n\nn,m = map(int,input().split())\n\ncnt = [0]*(10**5+4)\n\nyy = []\nyp = []\nfor _ in range(m):\n a,b = map(int,input().split())\n a,b = b,a\n yy.append([a,0])\n yp.append([a,b])\n\ninlist = copy.deepcopy(yp)\nyp.sort()\nyy = dict(yy)\n\nfor i in range(m):\n print(yp[i][1])\n cnt[yp[i][1]]+=1\n yy[yp[i][0]] = cnt[yp[i][1]]\n\nfor key,value in inlist:\n print("{:06}{:06}".format(value,yy[key]))', 'from operator import itemgetter\nimport numpy as np\nimport sys\n\ninput = sys.stdin.readline\nn,m = map(int,input().split())\n\nin_p = []\nin_y = []\nin_num = [0] * n\n\np = np.zeros((n,m))\nprint(p)\n\nfor i in range(m):\n a,b = map(int,input().split())\n in_p.append(a)\n in_y.append(b)\n p[a-1,i]= b\n in_num[a-1]+=1\n\np_sort=np.sort(p,axis=1)\nin_num = np.array(in_num)\nprint(p_sort)\nin_num = m - in_num\nfor i in range(m):\n year=str(in_p[i]).zfill(6)\n a = np.where(p_sort == in_y[i])\n b = int(a[1] - in_num[int(a[0])]+1 )\n print("{0}{1}".format(year,str(b).zfill(6)))\n\n\n\n\n', 'from operator import itemgetter\nimport sys\n\ninput = sys.stdin.readline\nn,m = map(int,input().split())\n\nin_p = []\nin_y = []\np = []\n\nfor _ in range(n):\n p.append([])\n\nfor i in range(m):\n a,b = map(int,input().split())\n in_p.append(a)\n in_y.append(b)\n p[a-1].append(b) \n\nfor i in range(n):\n p[i].sorted()\n\nfor i in range(m):\n year=str(in_p[i]).zfill(6)\n a = p[in_p[i]-1].index(in_y[i]) \n num=str(a).zfill(6)\n print("{0}{1}".format(year,num))\n\n', 'from operator import itemgetter\nimport numpy as np\nimport sys\n\ninput = sys.stdin.readline\nn,m = map(int,input().split())\n\nin_p = []\nin_y = []\nin_num = [0] * n\n\np = np.zeros((n,m))\n\nfor i in range(m):\n a,b = map(int,input().split())\n in_p.append(a)\n in_y.append(b)\n p[a-1,i]= b\n in_num[a-1]+=1\n\np_sort=np.sort(p,axis=1)\nin_num = np.array(in_num)\nin_num = m - in_num\nfor i in range(m):\n year=str(in_p[i]).zfill(6)\n a = np.where(p_sort == in_y[i])\n b = int(a[1] - in_num[int(a[0])]+1 )\n print("{0}{1}\\n".format(year,str(b).zfill(6)))', 'n,m = map(int,input().split())\n\nin_p = []\nin_y = []\np = []\n\nfor i in range(n):\n p.append([])\n\nfor i in range(m):\n a,b = map(int,input().split())\n in_p.append(a)\n in_y.append(b)\n p[a-1].append(b) \n\n p = sorted(p, key = lambda x:x[:])\n\nfor i in range(m):\n year=str(in_p[i]).zfill(6)\n a = p[in_p[i]-1].index(in_y[i]) + 1\n num=str(a).zfill(6)\n print("{0}{1}".format(year,num))\n\n', 'n,m = map(int,input().split())\n\nin_p = []\nin_y = []\np = []\n\nfor i in range(n):\n p.append([])\n\nfor i in range(m):\n a,b = map(int,input().split())\n in_p.append(a)\n in_y.append(b)\n p[a-1].append(b) \n\np = sorted(p, key = lambda x:x[:])\n\nfor i in range(m):\n year=str(in_p[i]).zfill(6)\n a = p[in_p[i]-1].index(in_y[i]) + 1\n num=str(a).zfill(6)\n print("{0}{1}".format(year,num))\n\n', 'n,m = map(int,input().split())\n\ndef func(l,x):\n return [i for i,_x in enumerate(l) if _x == x]\n\np = []\ny = []\nnumber = []\n\n\nfor i in range(m):\n a,b = map(int,input().split())\n for j in func(p,a):\n if y[j] > b:\n number[j] += 1\n\n p.append(a)\n y.append(b)\n number.append(1)\n\n\nfor i in range(m):\n year=str(p[i]).zfill(6)\n num=str(number[i]).zfill(6)\n print("{0}{1}\\n".format(year,num))\n', 'import copy\n\nn,m = map(int,input().split())\n\ncnt = [0]*(10**5+4)\n\nyy = []\nyp = []\nfor _ in range(m):\n a,b = map(int,input().split())\n a,b = b,a\n yy.append([a,0])\n yp.append([a,b])\n\ninlist = copy.deepcopy(yp)\nyp.sort()\nyy = dict(yy)\n\nfor i in range(m):\n cnt[yp[i][1]]+=1\n yy[yp[i][0]] = cnt[yp[i][1]]\n\nfor key,value in inlist:\n print("{:06}{:06}".format(value,yy[key]))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s082449034', 's316788413', 's347781470', 's382880399', 's861218827', 's957358571', 's967473636', 's852012088']
[60196.0, 1133340.0, 23080.0, 1135404.0, 18144.0, 33624.0, 3872.0, 60700.0]
[1274.0, 2113.0, 217.0, 2115.0, 2104.0, 2105.0, 2104.0, 1225.0]
[409, 585, 471, 559, 405, 401, 427, 389]
p03221
u850390157
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())\nbirth_list = []\nfor i in range(M):\n Pi, Yi = map(int, input().split())\n birth_list.append([Pi, Yi])\n\ncounter = -1\nprev_pref = -1\nfor city in sorted(birth_list, key=lambda x: (x[0], x[1])):\n print(city)\n if city[0] != prev_pref:\n counter = 1\n else:\n counter += 1\n identity_number = str(city[0]).zfill(6) + str(counter).zfill(6)\n city.append(identity_number)\n prev_pref = city[0]\n\nfor city in birth_list:\n print(city[2])', 'N, M = map(int, input().split())\nbirth_list = []\nfor i in range(M):\n Pi, Yi = map(int, input().split())\n birth_list.append([Pi, Yi])\n\ncounter = -1\nprev_pref = -1\nfor city in sorted(birth_list, key=lambda x: (x[0], x[1])):\n # print(city)\n if city[0] != prev_pref:\n counter = 1\n else:\n counter += 1\n identity_number = str(city[0]).zfill(6) + str(counter).zfill(6)\n city.append(identity_number)\n prev_pref = city[0]\n\nfor city in birth_list:\n print(city[2])']
['Wrong Answer', 'Accepted']
['s729405276', 's372839227']
[32976.0, 31052.0]
[850.0, 736.0]
[492, 494]
p03221
u853185302
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=[[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]\nprint(a)\nfor x,y in p:\n z=bisect.bisect(a[x],y)\n print("%06d%06d"%(x,z))', '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])\n\ncity = {}\nfor i in range(M):\n p, y = sort_PY[i][0], sort_PY[i][1]\n if p in city:\n city[p] += 1\n else:\n city[p] = 1\n sort_PY[i][2] = city[p]\n print(city)\nfor p, y, z in PY:\n print(str(p).zfill(6)+str(z).zfill(6))', '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', 'Wrong Answer', 'Accepted']
['s131694712', 's896590851', 's973929456']
[45604.0, 115880.0, 41012.0]
[727.0, 2105.0, 697.0]
[264, 361, 255]
p03221
u853952087
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())\nL=[[] for i in range(a)]\nl=[]\nll=[]\nu=0\nfor i in range(b):\n u+=1\n c=list(map(int,input().split()))\n c.append(u)\n L[int(c[0])-1].append(c)\n print(c,L)\nfor i in L:\n i.sort(key=lambda x:x[1])\nfor i in L:\n e=0\n for j in i:\n e+=1\n j.append(e)\nprint(L)\nq=[]\nfor w in L:\n q.extend(w) \nq.sort(key=lambda x:x[2])\nfor r in range(b):\n print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))", "a,b=map(int,input().split())\nL=[]\nl=[]\nll=[]\nu=0\nfor i in range(b):\n u+=1\n c=list(map(int,input().split()))\n c.append(u)\n L.append(c)\nL.sort(key=lambda x:x[0])\nfor i in range(1,a+1):\n lll=[]\n for j in L:\n if j[0]==i:\n lll.append(j)\n ll.append(lll)\nfor i in ll:\n e=0\n for j in i:\n e+=1\n j.append(e)\nq=[]\nfor w in ll:\n q.extend(w) \nq.sort(key=lambda x:x[2])\nfor r in range(b):\n print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))", 'a,b=map(int,input().split())\nL=[[] for i in range(a)]\nu=0\n\nfor i in range(b):\n u+=1\n c=list(map(int,input().split()))\n c.append(u)\n L[int(c[0])-1].append(c)\n\nfor i in L:\n i.sort(key=lambda x:x[1])\n\nfor i in L:\n e=0\n for j in i:\n e+=1\n j.append(e)\nq=[]\nfor w in L:\n q.extend(w) #flatten\nq.sort(key=lambda x:x[2])\u3000\nfor r in range(b):\n print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))\u3000#zfill', 'a,b=map(int,input().split())\nL=[[] for i in range(a)]\nu=0\n\nfor i in range(b):\n u+=1\n c=list(map(int,input().split()))\n c.append(u)\n L[int(c[0])-1].append(c)\n\nfor i in L:\n i.sort(key=lambda x:x[1])\n\nfor i in L:\n e=0\n for j in i:\n e+=1\n j.append(e)\nq=[]\nfor w in L:\n q.extend(w)# flatten\n\nq.sort(key=lambda x:x[2])\nfor r in range(b):\n print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s007283402', 's195766587', 's263865830', 's293201884']
[124612.0, 34208.0, 3064.0, 43172.0]
[2104.0, 2105.0, 17.0, 923.0]
[484, 528, 724, 721]
p03221
u860649643
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\n\nN,M = map(int, input().split())\nX = np.ones((M,3), dtype=int)\nfor i in range(M):\n X[i, 0], X[i, 1] = map(int, input().split())\nfor i in range(N):\n print(np.argsort(X[X[:,0]==i, 1]))\n X[X[:,0]==i, 2] = np.argsort(X[X[:,0]==i, 1])+1\nfor i in range(M):\n print('{:06}{:06}'.format(X[i,0], X[i,2]))", "import numpy as np\n\nN,M = map(int, input().split())\nX = [list(map(int, input().split())) for _ in range(M)]\norder = [[] for _ in range(N)]\nfor p,y in X:\n order[p-1].append(y)\n#X = np.array(X, dtype=int)\nfor i in range(N):\n order[i] = np.argsort(np.argsort(order[i]))\ncnts = [0 for _ in range(N)]\nfor i in range(M):\n p = X[i][0]\n print('{:06}{:06}'.format(p, order[p-1][cnts[p-1]]+1) )\n cnts[p-1] += 1"]
['Wrong Answer', 'Accepted']
['s537219585', 's948748818']
[17120.0, 56728.0]
[2109.0, 1978.0]
[325, 415]
p03221
u860657719
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())\nPs =[]\nYs =[]\ndic = {}\nfor i in range(M):\n p, y = map(int, input().split())\n Ps.append(p)\n Ys.append(y)\n ls = dic.get(p, [])\n ls.append(y)\n dic[p] = ls.sort()\nfor i in range(M):\n p = Ps[i]\n y = Ys[i]\n number = dic[p].index(y) + 1\n strp = str(p)\n strn = str(number)\n print(strp.zfill(6) + strn.zfill(6))\n', 'N, M =map(int, input().split())\nPs =[]\nYs =[]\ndic = {}\nfor i in range(M):\n p, y = map(int, input().split())\n Ps.append(p)\n Ys.append(y)\n ls = dic.get(p, [])\n ls.append(y)\nfor p in Ps:\n ls = dic[p]\n ls.sort()\n dic[p] = ls\nfor i in range(M):\n p = Ps[i]\n y = Ys[i]\n number = dic[p].index(y) + 1\n strp = str(p)\n strn = str(number)\n print(strp.zfill(6) + strn.zfill(6))\n', 'N, M =map(int, input().split())\nls = []\npcount =[]\nfor i in range(N):\n pcount.append(0)\nfor i in range(M):\n p, y = map(int, input().split())\n ls.append([i, p, y])\nls.sort(key = lambda x:x[2])\n\nfor l in ls:\n pcount[l[1]-1] += 1\n l.append(pcount[l[1]-1])\nls.sort(key = lambda x:x[0])\nfor l in ls:\n print(str(l[1]).zfill(6) + str(l[3]).zfill(6))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s844674966', 's910970077', 's748905328']
[20164.0, 11060.0, 31824.0]
[356.0, 342.0, 696.0]
[371, 407, 361]
p03221
u864197622
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 = []\nY = []\nfor i in range(M):\n p, y = map(int, input().split())\n P.append(p)\n Y.append(y)\n\nA = [[] for i in range(N)]\n\nfor i in range(M):\n A[P[i]-1].append([i, Y[i]])\n \nfor i in range(N):\n A[i] = sorted(A[i], key=lambda x:x[1])\n\nR = [[] for i in range(M)]\n\ncc = 0\nfor i in range(N):\n c = 1\n for j in A[i]:\n R[cc] = str(10**12 + (i+1) * (10**6) + c)[1:]\n c += 1\n cc += 1\nfor r in R:\n print(r)', 'N, M = map(int, input().split())\nP = []\nY = []\nfor i in range(M):\n p, y = map(int, input().split())\n P.append(p)\n Y.append(y)\n\nA = [[] for i in range(N)]\n\nfor i in range(M):\n A[P[i]-1].append([i, Y[i]])\n \nfor i in range(N):\n A[i] = sorted(A[i], key=lambda x:x[1])\n\nR = [[] for i in range(M)]\n\ncc = 0\nfor i in range(N):\n c = 1\n for j in A[i]:\n R[j[0]] = str(10**12 + (i+1) * (10**6) + c)[1:]\n c += 1\n cc += 1\nfor r in R:\n print(r)']
['Wrong Answer', 'Accepted']
['s235087078', 's006068008']
[44692.0, 43868.0]
[857.0, 924.0]
[475, 477]
p03221
u866769581
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())\nlis = [list(input().split()) for _ in range(M)]\nans_lis = [0] * M\nlis_sort = sorted(lis)\nflag = lis_sort[0][0]\ni = 1\nfor x in lis_sort:\n if x[0] != flag:\n flag = x[0]\n i=1\n print('if')\n x[1] = '0'*(6-len(str(i)))+str(i)\n i+=1\nfor x in lis:\n print('0'*(6-len(x[0])),x[0],x[1],sep='')", 'N,M = map(int,input().split())\nflag = 0\nlis = [list(map(int,input().split())) for _ in range(M)]\nans_pra_lis = []\nans_beh_lis = [0] * M\nlis_sort = sorted(lis)\nfor _ in lis:\n s = str(0)*(6-len(str(_[0]))) + str(_[0])\n ans_pra_lis.append(s)\ni = 1\nfor _ in range(len(lis_sort)):\n if flag != lis_sort[_][0]:\n flag = lis_sort[_][0]\n i = 1\n ans_beh_lis[lis.index(lis_sort[_])] = str(0)*(6-len(str(i))) + str(i)\n i += 1\nfor x,y in zip(ans_pra_lis,ans_beh_lis):\n print(x,y)', "N,M = map(int,input().split())\nlis = [list(map(int,input().split())) for _ in range(M)]\nans_lis = [0] * M\nlis_sort = sorted(lis)\ni = 1\nflag = 0\nfor _ in range(len(lis_sort)):\n if flag != lis_sort[_][0]:\n flag = lis_sort[_][0]\n i = 1\n ans_lis[lis.index(lis_sort[_])] = str(i)\n i += 1\nfor x,y in zip(lis,ans_beh_lis):\n print('0'*(6-len(str(x[0]))),x[0],'0'*(6-len(y)),y,sep='')\n\n", "N,M = map(int,input().split())\nlis = [list(map(int,input().split())) for _ in range(M)]\nans_lis = [0] * M\nlis_sort = sorted(lis,key =lambda x:(x[0],x[1]))\nflag = lis_sort[0][0]\ni = 1\nfor x in lis_sort:\n if x[0] != flag:\n flag = x[0]\n i=1\n x[1] = '0'*(6-len(str(i)))+str(i)\n i+=1\nfor x in lis:\n print('0'*(6-len(str(x[0]))),str(x[0]),x[1],sep='')"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s795451710', 's940024919', 's988701549', 's896249984']
[35800.0, 37628.0, 29420.0, 40840.0]
[806.0, 2106.0, 2105.0, 831.0]
[347, 498, 404, 372]
p03221
u870793476
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()]\nid=[[int(i) for i in input().split()]+[j] for j in range(m)]\n\nprint(id)\n\npre_num=[0]*(n+1)\nans=[""]*m\n\nid.sort(key=lambda x:x[1])\n\nfor p,y,i in id:\n pre_num[p]+=1\n ans[i]=str(p).zfill(6)+str(pre_num[p]).zfill(6)\n \nprint("\\n".join(ans))\n', 'n,m=[int(i) for i in input().split()]\nid=[[int(i) for i in input().split()]+[j] for j in range(m)]\n\npre_num=[0]*(n+1)\nans=[""]*m\n\nid.sort(key=lambda x:x[1])\n\nfor p, y, i in id:\n pre_num[p] += 1\n ans[i] = str(p).zfill(6) + str(pre_num[p]).zfill(6)\n\nprint("\\n".join(ans))']
['Wrong Answer', 'Accepted']
['s918148035', 's254686452']
[38460.0, 34696.0]
[605.0, 546.0]
[283, 275]
p03221
u874320250
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())\nPY = [tuple(map(int, input().split())) for _ in range(M)]\n\ncity_count = [0]*(N+1)\nfor p, y in PY:\n city_count[p] += 1\nfor ken, count in enumerate(city_count):\n [print(str(1*10**12+ken*10**6+count)[1:]) for i in range(1,count+1)]\n', 'import sys\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nPY = [tuple(map(int, input().split())) for _ in range(M)]\n\ncity_count = [0]*(N+1)\nfor p, y in PY:\n city_count[p] += 1\nfor ken, count in enumerate(city_count):\n [print(str(1*10**12+ken*10**6+i)[1:]) for i in range(1,count+1)]\n', "import sys\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nPY = [map(int, input().split()) for i in range(M)]\nPYI = sorted((p, y, i+1) for i, (p, y) in enumerate(PY))\ndef gen():\n pre = -1\n count = -1\n for p, y, i in PYI:\n if p == pre:\n count += 1\n yield (i, str(1*10**12+p*10**6+count)[1:])\n else:\n count = 1\n yield (i, str(1*10**12+p*10**6+count)[1:])\n pre = p\nprint('\\n'.join(i[1] for i in sorted(gen())))\n "]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s400760653', 's846656906', 's303939348']
[19448.0, 19444.0, 68468.0]
[345.0, 354.0, 616.0]
[307, 303, 460]
p03221
u875769753
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())\nls = []\nfor i in range(M):\n P,Y = map(int,input().split())\n ls.append([i,P,Y])\nls.sort(key=lambda x:x[1])\nnum = 1\ncity = ls[0][1]\nfor i in range(M):\n if ls[i][1] == city:\n ls[i][2] = num\n num += 1\n else:\n num = 1\n ls[i][2] = num\n city = ls[i][1]\nls.sort(key=lambda x:x[0])\nfor i in range(M):\n print('{0:06d}'.format(ls[i][1])+'{0:06d}'.format(ls[i][2]))", "N,M = map(int,input().split())\nls = []\nfor i in range(M):\n P,Y = map(int,input().split())\n ls.append([P,Y,i])\nls.sort()\nnum = 1\ncity = ls[0][0]\nfor i in range(M):\n if ls[i][0] == city:\n ls[i][1] = num\n num += 1\n else:\n num = 1\n ls[i][1] = num\n city = ls[i][0]\n num += 1\nls.sort(key=lambda x:x[2])\nfor i in range(M):\n print('{0:06d}'.format(ls[i][0])+'{0:06d}'.format(ls[i][1]))"]
['Wrong Answer', 'Accepted']
['s727225920', 's962578671']
[30208.0, 30548.0]
[438.0, 487.0]
[434, 434]
p03221
u877415670
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(key=lambda x: (x[0],x[1]))\nprint(py)\n_dict = {}\n\nans=[]\nfor i in range(m):\n if not py[i][0] in _dict:\n _dict[py[i][0]]=1\n else:\n _dict[py[i][0]]+=1\n p="0"*(6-len(str(py[i][0])))+str(py[i][0])\n y="0"*(6-len(str(py[i][0])))+str(_dict[py[i][0]])\n ans.append([p+y,py[i][2]])\n\nans.sort(key=lambda x: x[1])\nfor i in range(m):\n print(ans[i][0])', 'n,m=map(int,input().split())\npy=[list(map(int,input().split()))+[i] for i in range(m)]\n\npy.sort(key=lambda x: (x[0],x[1]))\n_dict = {}\n\nans=[]\nfor i in range(m):\n if not py[i][0] in _dict:\n _dict[py[i][0]]=1\n else:\n _dict[py[i][0]]+=1\n p="0"*(6-len(str(py[i][0])))+str(py[i][0])\n y="0"*(6-len(str(_dict[py[i][0]])))+str(_dict[py[i][0]])\n ans.append([p+y,py[i][2]])\n\nans.sort(key=lambda x: x[1])\nfor i in range(m):\n print(ans[i][0])']
['Wrong Answer', 'Accepted']
['s916705349', 's189202896']
[51012.0, 48736.0]
[1049.0, 951.0]
[465, 462]
p03221
u879674287
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: state num\nM: city num\n"""\n\nstate_cnt = {}\ncity_id_dict = {}\n\n(N, M) = list(map(int, input().split()))\n\nfor z in range(M):\n (P, Y) = list(map(int, input().spilt()))\n\n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n state_num = str(P).zfill(6)\n city_num = str(Y).zfill(6)\n tmp_id = state_num + city_num\n city_id_dict[Y] = tmp_id\n \n\n# all_state = set(range(1, N+1, 1))\n# remain = set(all_state) - set(get_state)\n# for num in ramain:\n# tmp_id = str(num).zfill(6) + "0"*6\n# city_id_list.append(tmp_id)\n \n[print(city_id) for _, city_id in sorted(city_id_dict.items())]', '"""\nN: state num\nM: city num\n"""\n\nstate_cnt = {}\ncity_id_dict = {}\n\n(N, M) = list(map(int, input().split()))\n# N = 2\n# m = 3\n\nfor z in range(M):\n# p_y_list = [\n# [1, np.random.randint(100)]\n# ,[3, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n# ,[1, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n \n# ]\n# for (P, Y) in p_y_list:\n (P, Y) = list(map(int, input().split()))\n\n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n state_num = str(P).zfill(6)\n city_num = str(state_cnt[P]).zfill(6)\n tmp_id = state_num + city_num\n city_id_dict[Y] = tmp_id\n \n\n# all_state = set(range(1, N+1, 1))\n# remain = set(all_state) - set(get_state)\n# for num in ramain:\n# tmp_id = str(num).zfill(6) + "0"*6\n# city_id_list.append(tmp_id)\n \nfor _, city_id in sorted(city_id_dict.items()):\n print(city_id)', '(N, M) = list(map(int, input().split()))\n\nstate_cnt = {}\ncity_id_list = []\ncity_id_dict = {}\nfor z in range(M):\n# for (P, Y) in p_y_list:\n \n (P, Y) = list(map(int, input().split()))\n\n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n state_num = str(P).zfill(6)\n city_num = str(state_cnt[P]).zfill(6)\n tmp_id = state_num + city_num\n\n# city_id_list.append([Y, P, tmp_id])\n \n city_id_dict[Y] = tmp_id\n \n\ncity_id_dict = sorted(city_id_dict.items())\nfor cid in city_id_dict:\n print(cid[1])', "N, M = map(int, input().split(' '))\n\ncities = []\nfor i in range(M):\n p, y = map(int, input().split(' '))\n cities.append([p, y, i])\n\nsorted(cities, key=lambda x: x[1])\nsorted(cities, key=lambda x: x[0])\n\np = cities[0][0]\ncnt = 1\nfor i in range(M):\n\n if (cities[i][0] == p):\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n else:\n p = cities[i][0]\n cnt = 1\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n\nsorted(cities, key=lambda x: x[2])\n\nfor i in range(M):\n print(cities[i][3])\n", '"""\nN: state num\nM: city num\n"""\n\nstate_cnt = {}\ncity_id_dict = {}\n\n(N, M) = list(map(int, input().split()))\n# N = 3\n# m = 3\n\nfor z in range(M):\n# p_y_list = [\n# [1, np.random.randint(100)]\n# ,[3, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n# ,[1, np.random.randint(100)]\n# ,[2, np.random.randint(100)]\n \n# ]\n# for (P, Y) in p_y_list:\n (P, Y) = list(map(int, input().spilt()))\n\n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n state_num = str(P).zfill(6)\n city_num = str(state_cnt[P]).zfill(6)\n tmp_id = state_num + city_num\n city_id_dict[Y] = tmp_id\n \n\n# all_state = set(range(1, N+1, 1))\n# remain = set(all_state) - set(get_state)\n# for num in ramain:\n# tmp_id = str(num).zfill(6) + "0"*6\n# city_id_list.append(tmp_id)\n \nfor _, city_id in sorted(city_id_dict.items()):\n print(city_id)', 'from collections import defaultdict\nimport numpy as np\n\nn, m = map(int, input().split())\n\nlist_ans = []\nlist_y = []\npre_p = -1\np_y = defaultdict(list)\n\nfor i in range(m):\n p, y = map(int, input().split())\n p_y[p].append(y)\n\nfor p in p_y.keys():\n list_y = p_y[p]\n list_num = np.argsort(list_y)\n for num in list_num:\n ans = str(p).zfill(6) + str(num + 1).zfill(6)\n print(ans)\n', 'debug = 0\n"""\nN: state num\nM: city num\n"""\n\n\nif debug:\n N = 2\n m = 10\nelse:\n (N, M) = list(map(int, input().split()))\n\nif debug:\n p_y_list = [\n [1, 30]\n ,[1, 20]\n ,[1, 10]\n ,[1, 3]\n ,[2, 63]\n ,[2, 33]\n ,[2, 23]\n ,[3, 21]\n ,[3, 7]\n ]\n\ncity_id_list = []\nfor z in range(M):\n# for (P, Y) in p_y_list:\n \n if not debug:\n (P, Y) = list(map(int, input().split()))\n\n city_id_list.append([Y, P])\n \ncity_id_list = sorted( city_id_list, key= lambda x: x[0])\n\nstate_cnt = {}\ntmp_list = []\nfor (Y, P) in city_id_list:\n \n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)\n \n tmp_list.append([state_cnt[P], tmp_id])\n \nfor cid in sorted(tmp_list, key=lambda x: (x[0], x[1])):\n print(cid[1])', 'debug = 0\n"""\nN: state num\nM: city num\n"""\n\n\nif debug:\n N = 2\n m = 10\nelse:\n (N, M) = list(map(int, input().split()))\n\nif debug:\n p_y_list = [\n [1, 30]\n ,[1, 20]\n ,[1, 10]\n ,[1, 3]\n ,[2, 63]\n ,[2, 33]\n ,[2, 23]\n ,[3, 21]\n ,[3, 7]\n ]\n\ncity_id_list = []\n\nfor (P, Y) in p_y_list:\n \n if not debug:\n (P, Y) = list(map(int, input().split()))\n\n city_id_list.append([Y, P])\n \ncity_id_list = sorted( city_id_list, key= lambda x: x[0])\n\nstate_cnt = {}\ntmp_list = []\nfor (Y, P) in city_id_list:\n \n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)\n \n tmp_list.append([state_cnt[P], tmp_id])\n \nfor cid in sorted(tmp_list, key=lambda x: x[0]):\n print(cid[1])', 'debug = 0\n"""\nN: state num\nM: city num\n"""\n\n\nif debug:\n N = 2\n m = 10\nelse:\n (N, M) = list(map(int, input().split()))\n\nif debug:\n p_y_list = [\n [1, 30]\n ,[1, 20]\n ,[1, 10]\n ,[1, 3]\n ,[2, 63]\n ,[2, 33]\n ,[2, 23]\n ,[3, 21]\n ,[3, 7]\n ]\n\ncity_id_list = []\nfor z in range(M):\n# for (P, Y) in p_y_list:\n \n if not debug:\n (P, Y) = list(map(int, input().split()))\n\n city_id_list.append([Y, P])\n \ncity_id_list = sorted( city_id_list, key= lambda x: x[0])\n\nstate_cnt = {}\ntmp_list = []\nfor (Y, P) in city_id_list:\n \n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n tmp_id = str(P).zfill(6) + str(state_cnt[P]).zfill(6)\n \n tmp_list.append([state_cnt[P], tmp_id])\n \nfor cid in sorted(tmp_list, key=lambda x: x[0]):\n print(cid[1])', 'state_cnt = {}\ncity_id_dict = {}\n\n(N, M) = list(map(int, input().split()))\n\nfor z in range(M):\n (P, Y) = list(map(int, input().spilt()))\n city_num_list.append(Y)\n\n if P not in state_cnt.keys():\n state_cnt[P] = 1\n elif P in state_cnt.keys():\n state_cnt[P] += 1\n \n state_num = str(P).zfill(6)\n city_num = str(state_cnt[P]).zfill(6)\n tmp_id = state_num + city_num\n city_id_dict[Y] = tmp_id\n \n\n# all_state = set(range(1, N+1, 1))\n# remain = set(all_state) - set(get_state)\n# for num in ramain:\n# tmp_id = str(num).zfill(6) + "0"*6\n# city_id_list.append(tmp_id)\n \n[print(city_id) for _, city_id in sorted(city_id_dict.items())]', "N, M = map(int, input().split(' '))\n\ncities = []\nfor i in range(M):\n p, y = map(int, input().split(' '))\n cities.append([p, y, i])\n\ncities = sorted(cities, key=lambda x: x[1])\ncities = sorted(cities, key=lambda x: x[0])\n\np = cities[0][0]\ncnt = 1\nfor i in range(M):\n\n if (cities[i][0] == p):\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n else:\n p = cities[i][0]\n cnt = 1\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n\nsorted(cities, key=lambda x: x[2])\n\nfor i in range(M):\n print(cities[i][3])\n", "N, M = map(int, input().split(' '))\n\ncities = []\nfor i in range(M):\n p, y = map(int, input().split(' '))\n cities.append([p, y, i])\n\ncities = sorted(cities, key=lambda x: x[1])\ncities = sorted(cities, key=lambda x: x[0])\n\np = cities[0][0]\ncnt = 1\nfor i in range(M):\n\n if (cities[i][0] == p):\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n else:\n p = cities[i][0]\n cnt = 1\n cities[i].append(str(p).zfill(6) + str(cnt).zfill(6))\n cnt += 1\n\ncities = sorted(cities, key=lambda x: x[2])\n\nfor i in range(M):\n print(cities[i][3])\n"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s005791323', 's141827012', 's534823406', 's535986423', 's550212554', 's557551330', 's604681121', 's666164002', 's703366179', 's815286472', 's997714547', 's588505298']
[3064.0, 36728.0, 35500.0, 33868.0, 3064.0, 36812.0, 50616.0, 3064.0, 45548.0, 3064.0, 35032.0, 35548.0]
[17.0, 763.0, 798.0, 673.0, 17.0, 2110.0, 948.0, 17.0, 812.0, 17.0, 868.0, 868.0]
[721, 1010, 652, 571, 1010, 403, 918, 910, 910, 726, 589, 598]
p03221
u882359130
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(nm) for nm in input().split()]\nPY = []\nfor m in range(M):\n PY.append([int(py) for py in input().split()])\nPY.sort()\ni = 1\nprint("0"*(6-len(str(PY[0][0]))) + str(PY[0][0]) + "0"*(6-len(str(i))) + str(i))\nfor m in range(1, M):\n if PY[m-1][0] == PY[m][0]:\n print("0"*(6-len(str(PY[m][0]))) + str(PY[m][0]) + "0"*(6-len(str(i+1))) + str(i+1))\n else:\n i = 1\n print("0"*(6-len(str(PY[m][0]))) + str(PY[m][0]) + "0"*(6-len(str(i))) + str(i))', 'N, M = [int(nm) for nm in input().split()]\nPY = []\nfor m in range(M):\n PY.append([int(py) for py in input().split()] + [m])\n\nPY.sort(key=lambda x: (x[0], x[1]))\np_ID = PY[0][0]\ny_ID = 0\nID = []\nfor m in range(M):\n p, y, i = PY[m]\n if p == p_ID:\n y_ID += 1\n else: #p != p_ID:\n p_ID = p\n y_ID = 1\n iidd = "0"*(6-len(str(p_ID))) + str(p_ID) + "0"*(6-len(str(y_ID))) + str(y_ID)\n ID.append([iidd, i])\n\nID.sort(key=lambda x: x[1])\nfor m in range(M):\n print(ID[m][0])']
['Wrong Answer', 'Accepted']
['s534714811', 's159606229']
[22584.0, 41376.0]
[699.0, 968.0]
[458, 477]
p03221
u887207211
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())) + [0] for _ in range(M)]\nPY = sorted(PY, key = lambda x: (x[0], x[1]))\nd = {}\nfor py in PY:\n if(py[0] not in d):\n d[py[0]] = 1\n else:\n d[py[0]] += 1\n py[2] = d[py[0]]\nfor py in PY:\n print(str(py[0]).zfill(6) + str(py[2]).zfill(6))', 'import sys\n\nstdin = sys.stdin\n\nsn = lambda : stdin.readline().rstrip()\nan = lambda : map(int, stdin.readline().split())\nni = lambda : int(sn())\n\nn, m = an()\npy = []\nfor _ in range(m):\n py.append(list(an()) + [0])\n\nsortPy = sorted(py, key = lambda x : (x[0], x[1]))\n\nd = {}\nfor i, (p, y, n) in enumerate(sortPy):\n if p in d:\n d[p] += 1\n else:\n d[p] = 1\n sortPy[i][2] = d[p]\n\nfor p, y, n in py:\n print(str(p).zfill(6) + str(n).zfill(6))']
['Wrong Answer', 'Accepted']
['s420612053', 's770957003']
[35584.0, 36380.0]
[793.0, 563.0]
[309, 445]
p03221
u891217808
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\nn, m = map(int, input().split())\nl = []\ndic = defaultdict(list)\nfor i in range(m):\n p, y = map(int, input().split())\n dic[p].append(y)\n l.append([p, y])\nfor key, value in dic.items():\n dic[key] = sorted(value)\nfor p, y in l:\n print(str(p).zfill(6)+str(dic[p].index(y)+1).zfill(8))\n', 'from collections import defaultdict\nn, m = map(int, input().split())\nl = []\ndic = defaultdict(list)\nfor i in range(m):\n p, y = map(int, input().split())\n dic[p].append(y)\n l.append([p, y])\nfor key, value in dic.items():\n dic[key] = {num: index+1 for index,num in enumerate(sorted(value))}\nfor p, y in l:\n print(str(p).zfill(6)+str(dic[p][y]).zfill(6))\n']
['Wrong Answer', 'Accepted']
['s148174375', 's704300780']
[38708.0, 61880.0]
[2105.0, 784.0]
[332, 367]
p03221
u895515293
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\nmp = {}\nfor i in range(M):\n P,Y=map(int,input().split())\n if not P in mp:\n mp[P] = []\n mp[P].append(Y)\n\nfor k,li in sorted(mp.items()):\n for i, _ in enumerate(li):\n print('{:06d}{:06d}'.format(k, i+1))\n", "N,M=map(int,input().split())\n\nmp = {}\nfor i in range(M):\n P,Y=map(int,input().split())\n if not P in mp:\n mp[P] = []\n mp[P].append((Y,i))\n\nres = ['']*M\nfor k, li in sorted(mp.items()):\n for i, (y, l) in enumerate(sorted(li)):\n res[l] = '{:06d}{:06d}'.format(k, i+1)\n\nfor st in res: print(st)\n"]
['Wrong Answer', 'Accepted']
['s852432985', 's657533830']
[35024.0, 50248.0]
[647.0, 756.0]
[258, 317]
p03221
u896517320
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 = input().split()\nl1 = []\nfor i in range(int(n[1])):\n l1.append(input().split())\n\nfor i in range(int(n[1])):\n for j in range(2):\n l1[i][j] = int(l1[i][j])\n\nprint(l1)\nm = 0\nfor k in l1:\n k.append(m)\n m += 1\n\nprint(l1)\nl3 = sorted(l1)\nprint(l3)\n\nl3[0][1] = 1\nfor i in range(1,len(l3)):\n if l3[i][0]==l3[i-1][0]:\n l3[i][1]=l3[i-1][1]+1\n else:\n l3[i][1]=1\n\nfor i in range(len(l3)):\n l3[i][2],l3[i][0]=l3[i][0],l3[i][2]\nfor i in range(len(l3)):\n l3[i][1],l3[i][2]=l3[i][2],l3[i][1]\nl3.sort()\n\n\nfor i in range(int(n[1])):\n for j in range(2):\n l3[i][j] = str(l3[i][j])\n\nfor i in range(len(l3)):\n print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))', 'n = input().split()\nl1 = []\nfor i in range(int(n[1])):\n l1.append(input().split())\n\nfor i in range(int(n[1])):\n for j in range(2):\n l1[i][j] = int(l1[i][j])\n\n\nm = 0\nfor k in l1:\n k.append(m)\n m += 1\n\n\nl3 = sorted(l1)\n\n\nl3[0][1] = 1\nfor i in range(1,len(l3)):\n if l3[i][0]==l3[i-1][0]:\n l3[i][1]=l3[i-1][1]+1\n else:\n l3[i][1]=1\n\nfor i in range(len(l3)):\n l3[i][2],l3[i][0]=l3[i][0],l3[i][2]\nfor i in range(len(l3)):\n l3[i][1],l3[i][2]=l3[i][2],l3[i][1]\nl3.sort()\n\n\nfor i in range(int(n[1])):\n for j in range(2):\n l3[i][j] = str(l3[i][j])\n\nfor i in range(len(l3)):\n print(str(l3[i][1]).zfill(6)+str(l3[i][2]).zfill(6))']
['Wrong Answer', 'Accepted']
['s680527733', 's613526855']
[54772.0, 47268.0]
[1211.0, 1069.0]
[701, 674]
p03221
u896741788
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.
['#C-ID\nn,m=map(int,input().split())\nL={}\nlp=[[] for _ in range(n)]\nfor cn in range(m):\n p,y=map(int,input().split())\n lp[p-1].append([y,cn])\n lp[p-1]=sorted(lp[p-1])\nfor pre in range(n):\n k=len(lp[pre])\n if k>0:\n for d in range(k):\n cn=lp[pre][k][1]\n ans="0"*(6-len(str(pre)))+str(pre)+"0"*(6-len(str(d+1)))+str(d+1)\n L[cn]=ans\nfor h in range(m):\n print(L[h])', '#C-ID\nn,m=map(int,input().split())\nL={}\nlp=[list() for _ in range(n)]\nfor cn in range(m):\n p,y=map(int,input().split())\n lp[p-1].append([y,cn])\nfor pre in range(n):\n k=len(lp[pre])\n if k>0:\n sd=lp[pre]\n asd=sorted(sd)\n for d in range(k):\n cn=asd[d][1]\n ans="0"*(6-len(str(pre+1)))+str(pre+1)+"0"*(6-len(str(d+1)))+str(d+1)\n L[cn]=ans\nfor h in range(m):\n print(L[h])']
['Runtime Error', 'Accepted']
['s308097938', 's403361956']
[30496.0, 45472.0]
[2105.0, 795.0]
[413, 425]
p03221
u897328029
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# C - ID\n\nn, m = list(map(int, input().split()))\npy_list = []\n\nfor _ in range(m):\n p, y = list(map(int, input().split()))\n py_list.append((p, y))\n\npy_list = sorted(py_list, key=lambda x: (x[0], x[1]))\n\np_no = py_list[0][0]\ny_index = 1\nno_list = []\n\nfor i, py in enumerate(py_list):\n p, y = py\n\n if p != p_no:\n p_no = p\n y_index = 1\n\n no = str(p).zfill(6) + str(y_index).zfill(6)\n no_list.append(no)\n y_index += 1\n\n\nans = '\\n'.join(no_list)\nprint(ans)\n", "\n# C - ID\n\nn, m = list(map(int, input().split()))\npy_list = []\n\nfor _ in range(m):\n p, y = list(map(int, input().split()))\n py_list.append((p, y))\n\npy_list = sorted(py_list, key=lambda x: (x[0], x[1]))\n\np_no = py_list[0][0]\np_index = 1\ny_index = 1\nno_list = []\n\nfor i, py in enumerate(py_list):\n p, y = py\n\n if p != p_no:\n p_no = p\n p_index += 1\n y_index = 1\n\n no = str(p_index).zfill(6) + str(y_index).zfill(6)\n no_list.append(no)\n y_index += 1\n\n\nans = '\\n'.join(no_list)\nprint(ans)\n", "\n# C - ID\n\nn, m = list(map(int, input().split()))\npy_list = []\n\nfor _ in range(m):\n p, y = list(map(int, input().split()))\n py_list.append((p, y))\n\nsorted_py_list = sorted(py_list, key=lambda x: (x[0], x[1]))\n\np_no = sorted_py_list[0][0]\ny_index = 1\nno_dict = {}\n\nfor i, py in enumerate(sorted_py_list):\n p, y = py\n\n if p != p_no:\n p_no = p\n y_index = 1\n\n no = str(p).zfill(6) + str(y_index).zfill(6)\n no_dict[(p, y)] = no\n y_index += 1\n\nprint_list = []\n\nfor p, y in py_list:\n print_list.append(no_dict[(p, y)])\n\nans = '\\n'.join(print_list)\nprint(ans)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s336131646', 's947020832', 's382856184']
[27628.0, 27596.0, 40788.0]
[619.0, 633.0, 734.0]
[538, 577, 641]
p03221
u903948194
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 = []\nY = []\nvar = []\nfor i in range(M):\n p, y = map(int, input().split())\n if p not in P:\n var.append(p)\n P.append(p)\n Y.append(y)\n\nL = zip(range(M), P, Y) \n\nOrder = [None]*M\n\nfor v in var:\n l = filter(lambda x:x[1] == v, L)\n l_ = sorted(l, key = lambda x:x[2])\n \n for n in l_:\n Order[n[0]] = l_.index(n)+1\n \nfor (p, od) in zip(P, Order):\n print('{0:0>6d}{1:0>6d}'.format(p, od))", "N, M = map(int, input().split())\nP = []\nY = []\n#var = []\nfor i in range(M):\n p, y = map(int, input().split())\n #if p not in P:\n # var.append(p)\n P.append(p)\n Y.append(y)\n\nL = zip(range(M), P, Y) \n\nOrder = [None]*M\n\nfor v in set(P):\n l = filter(lambda x:x[1] == v, L)\n l_ = sorted(l, key = lambda x:x[2])\n \n for n in l_:\n Order[n[0]] = l_.index(n)+1\n \nfor (p, od) in zip(P, Order):\n print('{0:0>6d}{1:0>6d}'.format(p, od))", "N, M = map(int, input().split())\nP = []\nY = []\nvar = []\nfor i in range(M):\n p, y = map(int, input().split())\n if p in P:\n var.append(p)\n P.append(p)\n Y.append(y)\n\nL = zip(range(M), P, Y) \n\nOrder = [None]*M\n\nfor v in var:\n l = filter(lambda x:x[1] == v, L)\n l_ = sorted(l, key = lambda x:x[2])\n \n for n in l_:\n Order[n[0]] = l_.index(n)+1\n \nfor (p, od) in zip(P, Order):\n print('{0:0>6d}{1:0>6d}'.format(p, od))", "N, M = map(int, input().split())\nL = []\nP = [0]*(N+1)\nfor i in range(M):\n p, y = map(int, input().split())\n L.append([i, p, y, 0])\n\nL = sorted(L, key = lambda x:x[2])\n\nfor l in L:\n P[l[1]] += 1\n l[3] = P[l[1]] \n \nfor l in sorted(L, key = lambda x:x[0]):\n print('{0:0>6d}{1:0>6d}'.format(l[1], l[3]))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s022184601', 's107842885', 's884713148', 's883866826']
[24528.0, 24520.0, 25308.0, 30612.0]
[2105.0, 2105.0, 2105.0, 708.0]
[466, 472, 462, 324]
p03221
u909162870
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.
['m = nm[1]\nall_city = list()\nfor i in range(m):\n py = list(map(int, input().split()))\n py.append(i)\n all_city.append(py)\nac_list = copy.deepcopy(all_city)\nac_list.sort()\nac_dict = {}\na = 0\nb = 0\nfor i in range(m):\n if ac_list[i][0] == a:\n b += 1\n else:\n a += 1\n b = 1\n ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))\nfor i in range(m):\n print(ac_dict.get(all_city[i][2]))', 'import copy\nnm = list(map(int, input().split()))\nn = nm[0]\nm = nm[1]\nall_city = list()\nfor i in range(m):\n py = list(map(int, input().split()))\n py.append(i)\n all_city.append(py)\nac_list = copy.deepcopy(all_city)\nac_list.sort()\nac_dict = {}\na = 0\nb = 0\nfor i in range(m):\n if ac_list[i][0] == a:\n b += 1\n else:\n a = ac_list[i][0]\n b = 1\n ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))\nfor i in range(m):\n print(ac_dict.get(all_city[i][2]))\n']
['Runtime Error', 'Accepted']
['s287649322', 's531660884']
[3064.0, 58856.0]
[17.0, 1271.0]
[428, 499]
p03221
u912115033
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())\nc = {}\nfor _ in range(m):\n p, y = map(int,input().split())\n if p in c:\n c[p] += 1\n else:\n c[p] = 1\ncs = sorted(c.items(), key=lambda x:x[0])\nfor i in cs:\n for j in range(i[1]):\n print(str(i[0]).zfill(6) + str(j+1).zfill(6))\n', 'n, m = map(int,input().split())\nPY = []\nfor _ in range(m):\n PY.append(list(map(int,input().split())))\nsortedPY = sorted(PY, key=lambda x: x[1])\n\nd = {}\no = [1]*(n+1)\nfor i in sortedPY:\n d[(i[0],i[1])] = o[i[0]]\n o[i[0]] += 1\n\nfor i in PY:\n print(str(i[0]).zfill(6) + str(d[(i[0],i[1])]).zfill(6))\n']
['Wrong Answer', 'Accepted']
['s571692880', 's673776985']
[21472.0, 46584.0]
[510.0, 723.0]
[289, 309]
p03221
u917872021
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()))\ncities = []\n\nfor i in range(m):\n p, y = list(map(int, input().split()))\n cities.append([p, y, i])\n\nsorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))\nprint(sorted_cities)\ncnt = 1\nans = []\nfor i in range(m-1):\n p_id = str(sorted_cities[i][0]).rjust(6, '0')\n c_id = str(cnt).rjust(6, '0')\n ans.append([sorted_cities[i][2], p_id+c_id])\n if sorted_cities[i][0] != sorted_cities[i+1][0]:\n cnt = 1\n else:\n cnt += 1\n\np_id = str(sorted_cities[m-1][0]).rjust(6, '0')\nc_id = str(cnt).rjust(6, '0')\nans.append([sorted_cities[m-1][2], p_id+c_id])\nans.sort()\n\nfor id in ans:\n print(id[1])\n\n", "n, m = list(map(int, input().split()))\ncities = []\n\nfor i in range(m):\n p, y = list(map(int, input().split()))\n cities.append([p, y, i])\n\nsorted_cities = sorted(cities, key=lambda x: (x[0], x[1]))\ncnt = 1\nans = []\nfor i in range(m-1):\n p_id = str(sorted_cities[i][0]).rjust(6, '0')\n c_id = str(cnt).rjust(6, '0')\n ans.append([sorted_cities[i][2], p_id+c_id])\n if sorted_cities[i][0] != sorted_cities[i+1][0]:\n cnt = 1\n else:\n cnt += 1\n\np_id = str(sorted_cities[m-1][0]).rjust(6, '0')\nc_id = str(cnt).rjust(6, '0')\nans.append([sorted_cities[m-1][2], p_id+c_id])\nans.sort()\n\nfor id in ans:\n print(id[1])\n\n"]
['Wrong Answer', 'Accepted']
['s483308137', 's720201647']
[45152.0, 45236.0]
[804.0, 736.0]
[662, 641]
p03221
u919235786
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(n):\n a.append(0)\nfor i in range(m):\n pi,yi=map(int,input().split())\n a[pi-1]+=1\nfor i in range(len(a)):\n for j in range(a[i]):\n print('{0:06d}{1:06d}'.format(i+1,j+1))\n\n", "from operator import itemgetter\nn,m=map(int,input().split())\na=[]\nfor i in range(m):\n pi,yi=map(int,input().split())\n a.append([i,pi,yi])\nb=[]\nc=[]\nfor i in range(n):\n b.append([])\n c.append([])\nfor i in range(m):\n x=a[i][0]\n y=a[i][2]\n b[a[i][1]-1].append([x,y])\n\nfor i in range(n):\n b[i].sort(key=itemgetter(1))\n l=len(b[i])\n for j in range(l):\n a[b[i][j][0]].append(j+1)\nprint(a)\nfor i in range(m):\n xi=a[i][1]\n yi=a[i][3]\n print('{0:06d}{1:06d}'.format(xi,yi))", "n,m=map(int,input().split())\np=[]\npp=[1]\npp*=n\nans=[]\nfor i in range(n):\n p.append([])\nfor i in range(m):\n pi,yi=map(int,input().split())\n p[pi-1].append([yi,pp[pi-1]])\n ans.append([pi-1,pp[pi-1]])\n pp[pi-1]+=1\n print(p)\nfor i in range(n):\n p[i].sort()\nfor i in range(m):\n b=len(p[ans[i][0]])\n for j in range(b):\n if ans[i][1]==p[ans[i][0]][j][1]:\n print('{0:06d}{1:06d}'.format(ans[i][0]+1,j+1))\n break", "from operator import itemgetter\nn,m=map(int,input().split())\na=[]\nfor i in range(m):\n pi,yi=map(int,input().split())\n a.append([i,pi,yi])\nb=[]\nc=[]\nfor i in range(n):\n b.append([])\n c.append([])\nfor i in range(m):\n x=a[i][0]\n y=a[i][2]\n b[a[i][1]-1].append([x,y])\n\nfor i in range(n):\n b[i].sort(key=itemgetter(1))\n l=len(b[i])\n for j in range(l):\n a[b[i][j][0]].append(j+1)\nfor i in range(m):\n x=a[i][1]\n y=a[i][3]\n print('{0:06d}{0:06d}'.format(x,y))\n\n", "from operator import itemgetter\nn,m=map(int,input().split())\na=[]\nfor i in range(m):\n pi,yi=map(int,input().split())\n a.append([i,pi,yi])\nb=[]\nc=[]\nfor i in range(n):\n b.append([])\n c.append([])\nfor i in range(m):\n x=a[i][0]\n y=a[i][2]\n b[a[i][1]-1].append([x,y])\n\nfor i in range(n):\n b[i].sort(key=itemgetter(1))\n l=len(b[i])\n for j in range(l):\n a[b[i][j][0]].append(j+1)\nfor i in range(m):\n xi=a[i][1]\n yi=a[i][3]\n print('{0:06d}{1:06d}'.format(xi,yi))\n\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s043686133', 's173492082', 's209046130', 's693934214', 's714212923']
[5192.0, 65068.0, 147000.0, 56064.0, 56068.0]
[537.0, 1071.0, 2417.0, 1026.0, 1005.0]
[237, 510, 459, 499, 503]
p03221
u919689206
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\nl = [[] for i in range(n)]\n\nfor i in range(m):\n p, y = map(int, input().split())\n print('p:{} y:{} i:{}'.format(p, y, i))\n l[ p - 1 ].append(y)\n \nfor i in range(len(l)):\n for j in range(len(l[i])):\n print('{ken:06}{shi:06}'.format(ken=i+1, shi=j+1))", "\nn, m = map(int, input().split())\n\nl = [0 for i in range(n)]\n\nfor i in range(m):\n p, y = map(int, input().split())\n #print('p:{} y:{} i:{}'.format(p, y, i))\n l[ p - 1 ] += 1\n\nshi = 1\ndef out(l, cnt):\n \n if any([True for i in l if i > 0]):\n global shi\n \n for i in range(len(l)):\n if l[i] > 0:\n print('{ken:06}{shi:06}'.format(ken=i+1, shi=shi)) \n \n shi+=1\n return out([i - 1 for i in l], cnt+1)\n else:\n return\n\nout(l, 1)\n\n", "n, m = map(int, input().split())\n\nl = []\nans = [0] * m\n\nfor i in range(m):\n l.append([int(j) for j in input().split()])\n l[i].append(i)\n\n\nl2 = sorted(l, key=lambda x:(x[0],x[1]))\ncnt = 1\n\nfor i in range(m):\n \n l2[i][1] = cnt\n \n if i < m -1 and l2[i][0] == l2[i + 1][0]:\n cnt += 1\n else:\n cnt = 1\n\n ans[l2[i][2]] = '{:06}{:06}'.format(l2[i][0],l2[i][1])\n\nfor s in ans:\n print(s)"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s166523917', 's841384395', 's154689468']
[22064.0, 549584.0, 33948.0]
[1248.0, 2139.0, 757.0]
[361, 522, 443]
p03221
u919730120
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=[[0]*3 for _ in range(m)]\nfor i in range(m):\n p,y=map(int,input().split())\n py[i][0],py[i][1],py[i][2]=p,y,i\npy.sort()\nans=[[''] for _ in range(m)]\ncnt=[0]*m\nfor p,y,i in py:\n cnt[p]+=1\n ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])\nans.sort()\nfor i in ans:\n print(i)", "def resolve():\n n,m=map(int,input().split())\n py=[[0]*3 for _ in range(m)]\n for i in range(m):\n p,y=map(int,input().split())\n py[i][0],py[i][1],py[i][2]=p,y,i\n py.sort()\n ans=[[''] for _ in range(m)]\n cnt=[0]*(n+1)\n for p,y,i in py:\n cnt[p]+=1\n ans[i]='0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(cnt[p])))+str(cnt[p])\n for i in ans:\n print(i)\n\n\nif __name__ == '__main__':\n resolve()"]
['Runtime Error', 'Accepted']
['s429330798', 's115199111']
[33832.0, 34040.0]
[820.0, 719.0]
[339, 442]
p03221
u921773161
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 = [0] * M\nY = [0] * M\ncheck = [[] for i in range(N)]\n\nfor i in range(M):\n P[i], Y[i] = map(int, input().split())\n check[P[i]-1].append(Y[i])\n\nfor i in range(N):\n check[i].sort()\n', "N, M = map(int, input().split())\nP = [0] * M\nY = [0] * M\nX = [0] * M\ncheck = [[] for i in range(N)]\n\nfor i in range(M):\n P[i], Y[i] = map(int, input().split())\n X[i] = [Y[i], P[i], i]\n\nX.sort()\n#print(X)\n\ncount = [0] * (N+1)\nans_list = [[] for _ in range(M)]\n\nfor i in range(len(X)):\n count[X[i][1]] += 1\n tmp = ('000000'+ str(X[i][1]))[-6:] + ('000000'+ str(count[X[i][1]]))[-6:]\n ans_list[X[i][2]] = tmp\n\nfor i in range(len(ans_list)):\n print(ans_list[i])"]
['Wrong Answer', 'Accepted']
['s686441808', 's728677013']
[22632.0, 41072.0]
[401.0, 808.0]
[222, 475]
p03221
u921811474
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())\nh = [list(map(int, input().split()))for i in range(M)]\nfor i in range(M):\n h[i].append(i)\nh = sorted(h,key=lambda h:(h[0],-h[1]))\nk = 0\nfor i in range(M):\n if h[i][0] == 1:\n h[i].append("000001")\n h[i].append(str(i+1).zfill(6))\n else:\n h[i].append("000002")\n h[i].append(str(k+1).zfill(6))\n k += 1\nh = sorted(h,key=lambda h:h[2])\nfor i in range(M):\n print(h[i][3]+h[i][4])', 'N,M = map(int,input().split())\nh = [list(map(int, input().split()))for i in range(M)]\nfor i in range(M):\n h[i].append(i)\nh = sorted(h,key=lambda h:(h[0],h[1]))\nk = 0\np = h[0][0]\nfor i in range(M):\n if h[i][0] == p:\n h[i].append(str(p).zfill(6)+str(k+1).zfill(6))\n k+=1\n else:\n p = h[i][0]\n k = 0\n h[i].append(str(p).zfill(6) + str(k + 1).zfill(6))\n k += 1\n# print(h)\nh = sorted(h,key=lambda h:h[2])\n# print(h)\nfor i in range(M):\n print(h[i][3])']
['Wrong Answer', 'Accepted']
['s204432757', 's518507570']
[43140.0, 39572.0]
[775.0, 802.0]
[450, 498]
p03221
u923341003
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 = []\ny = []\nfor i in range(M):\n p1,y1=[int(i) for i in input().split()]\n p.append(p1)\n y.append(y1)\nfor idx in range(M):\n ans[idx] = [idx, p[idx], y[idx]]\nans = sorted(ans, key=lambda x: x[1])\nans = sorted(ans, key=lambda x: x[2])\nfor idx in range(M):\n if idx == 0:\n ans[idx][2] = 1\n else:\n if ans[idx][1] == ans[idx-1][1]:\n ans[idx][2] = ans[idx-1][2] + 1\n else:\n ans[idx][2] = 1\nans = sorted(ans, key=lambda x: x[0])\nfor idx in range(M):\n print('{:0=6}{:0=6}'.format(ans[idx][1], ans[idx][2]))", "N, M = map(int, input().split())\nanses = [0] * M\npre = [0] * N\n \nfor idx in range(M):\n p, y = (int(x) for x in input().split())\n anses[idx] = [idx, p, y, 0]\n\nanses = sorted(anses, key=lambda x: x[2])\n\nfor ans in anses:\n pre[ans[1]-1] += 1\n ans[3] = pre[ans[1]-1]\n\nanses = sorted(anses, key=lambda x: x[0])\n\nfor ans in anses:\n print('{:0=6}{:0=6}'.format(ans[1], ans[3]))"]
['Runtime Error', 'Accepted']
['s403890098', 's087040665']
[11048.0, 30620.0]
[317.0, 710.0]
[594, 385]
p03221
u924770834
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\nimport math\nfrom collections import defaultdict\n\nn,m = input().split()\nn = int(n)\nm = int(m)\nP,Y = [],[]\nfor _ in range(m):\n\tp,y = input().split()\n\tP.append(p)\n\tY.append(y)\n\nP = [int(p) for p in P]\nY = [int(y) for y in Y]\n\nprint(P)\nprint(Y)\n\nsorted = defaultdict(list)\n\nfor i in range(m):\n\tsorted[P[i]].append(Y[i])\n\nfor k in sorted.keys():\n\tsorted[k].sort()\n\nfor i in range(m):\n\tprint("{0:06}{1:06}".format(P[i], sorted[P[i]].index(Y[i])+1))', 'import numpy as np\nimport math\nfrom collections import defaultdict\n\nn,m = input().split()\nn = int(n)\nm = int(m)\nP,Y = [],[]\nfor _ in range(m):\n\tp,y = input().split()\n\tP.append(p)\n\tY.append(y)\n\nP = [int(p) for p in P]\nY = [int(y) for y in Y]\n\nsorted = defaultdict(list)\n\nsorted = [[] for i in range(n)]\n\nfor i,(p,y) in enumerate(zip(P,Y)):\n\tsorted[p-1].append((y,i))\n\nans = [None]*m\nfor i, d in enumerate(sorted):\n\td.sort()\n\tfor k, (y, j) in enumerate(d):\n\t\tans[j] = "%06d%06d" % (i+1,k+1)\nprint(*ans, sep=\'\\n\')\n\n']
['Wrong Answer', 'Accepted']
['s789564928', 's204806129']
[44792.0, 55600.0]
[2110.0, 847.0]
[461, 512]
p03221
u931462344
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())\nxs = [0]*m\npre = [0]*m\nfor x in range(m):\n xs[x] = list(list(map(int,input().split())) + [x] + [x])\nxs.sort()\n\nprint(xs)\nskip = 0\nfor p in range(1,n+1):\n cnt = 1\n flag = 0\n for x in range(skip,len(xs)):\n if xs[x][0] <= p:\n xs[x][3] = cnt\n cnt += 1\n skip += 1\n else:\n flag = 1\n if flag:\n break\n\n\nfor x in sorted(xs, key=lambda x:x[2]):\n print('{0:06d}'.format(x[0]) + '{0:06d}'.format(x[3]))\n", "n, m = map(int,input().split())\nxs = [0]*m\npre = [0]*m\nfor x in range(m):\n xs[x] = list(list(map(int,input().split())) + [x] + [x])\nxs.sort()\n\nskip = 0\nfor p in range(1,n+1):\n cnt = 1\n flag = 0\n for x in range(skip,len(xs)):\n if xs[x][0] <= p:\n xs[x][3] = cnt\n cnt += 1\n skip += 1\n else:\n flag = 1\n if flag:\n break\n\n\nfor x in sorted(xs, key=lambda x:x[2]):\n print('{0:06d}'.format(x[0]) + '{0:06d}'.format(x[3]))\n"]
['Wrong Answer', 'Accepted']
['s552190979', 's211513849']
[41792.0, 37056.0]
[1078.0, 1024.0]
[514, 504]
p03221
u932465688
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 L.append(list(map(int,input().split())))\nfor j in range(M):\n L[j].append(j)\nL.sort()\nl = L[0][0]\ncnt = 0\nfor k in range(M):\n if l == L[k][0]:\n L[k].append(cnt)\n cnt += 1\n else:\n l = L[k][0]\n cnt = 0\n L[k].append(cnt)\nL = sorted(L, key = lambda x:x[2])\nprint(L)\nfor i in range(M):\n print('0'*(6-len(str(L[i][0])))+str(L[i][0])+'0'*(6-len(str(L[i][3]+1)))+str(L[i][3]+1))", "N,M = map(int,input().split())\nL = []\nfor i in range(M):\n L.append(list(map(int,input().split())))\nfor j in range(M):\n L[j].append(j)\nL.sort()\nprint(L)\nl = L[0][0]\ncnt = 0\nfor k in range(M):\n if l == L[k][0]:\n cnt += 1\n L[k].append(cnt)\n else:\n l = L[k][0]\n cnt = 1\n L[k].append(cnt)\nprint(L)\nL = sorted(L, key = lambda x:x[2])\nfor i in range(M):\n print('0'*(6-len(str(L[i][0])))+str(L[i][0])+'0'*(6-len(str(L[i][3])))+str(L[i][3]))\n", 'N,M = map(int,input().split())\nL = []\nfor i in range(M):\n L.append(list(map(int,input().split())))\nfor i in range(M):\n L[i].append(i)\ncnt = [0]*N\nL = sorted(L, key = lambda x:x[1])\nfor i in range(M):\n L[i].append(cnt[L[i][0]-1])\n cnt[L[i][0]-1] += 1\nL = sorted(L, key = lambda x:x[2])\nfor i in range(M):\n ID = str(L[i][0]).zfill(6)+str(L[i][3]+1).zfill(6)\n print(ID)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s355965329', 's720686302', 's882884195']
[44500.0, 46552.0, 36840.0]
[882.0, 1031.0, 709.0]
[447, 453, 372]
p03221
u932868243
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)]\nl=[[] for j in range(n)]\nfor p,y in py:\n l[p-1].append(y)\nfor j in range(n):\n l[j].sort()\nfor j in range(n):\n for t in range(len(l[j])):\n pre='0'*(6-len(str(l[j][t])))+str(l[j][t])\n y='0'*(6-len(str(t+1)))+str(t+1)\n print(pre+y)", "n,m=map(int,input().split())\npy=[list(map(int,input().split())) for i in range(m)]\nl=[[] for j in range(n)]\nfor p,y in py:\n l[p-1].append(y)\nfor j in range(n):\n l[j].sort()\n\nfor j in range(n):\n for t in len(l[j]):\n pre='0'*(6-len(str(l[j][t])))+str(l[j][t])\n y='0'*(6-len(str(t+1)))+str(t+1)\n print(pre+str)", "n,m=map(int,input().split())\npy=[list(map(int,input().split())) for i in range(m)]\nl=[[] for j in range(n)]\nfor p,y in py:\n l[p-1].append(y)\nfor j in range(n):\n l[j].sort()\nfor j in range(n):\n for t in range(len(l[j])):\n pre='0'*(6-len(str(j+1)))+str(j+1)\n y='0'*(6-len(str(t+1)))+str(t+1)\n print(pre+y)", "n,m=map(int,input().split())\n\nl=[[] for j in range(n)]\nfor i in range(m):\n p,y=map(int,input().split())\n l[p-1].append([y,i])\nfor j in range(n):\n l[j].sort(key=lambda x:x[0])\nlis=[]\nfor j in range(n):\n for t in range(len(l[j])):\n pre='0'*(6-len(str(j+1)))+str(j+1)\n y='0'*(6-len(str(t+1)))+str(t+1)\n b=pre+y\n lis.append([b,l[j][t][1]])\nlis.sort(key=lambda x:x[1])\nfor li in lis:\n print(li[0])"]
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s008519600', 's292548215', 's711689432', 's675528624']
[37108.0, 35760.0, 36708.0, 48716.0]
[725.0, 419.0, 684.0, 1016.0]
[323, 319, 315, 409]
p03221
u933622697
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.
['# WIP\nimport sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\n\npy_list = [tuple(map(int, input().split())) for m in range(m)]\npy_list.sort(key=lambda x: x[1])\n\nprint(py_list)\n\ncursor_p = 1\ncurrent = 0\ncity = None\nfor py in py_list:\n p = py[0]\n y = py[1]\n\n if p == cursor_p:\n current += 1\n elif p > cursor_p:\n current = 1\n cursor_p = p\n city = str(current).zfill(6)\n pref = str(cursor_p).zfill(6)\n\n print(pref+city)\n', 'import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\n\npy_list = [tuple(map(int, input().split())) for m in range(m)]\npy_list.sort(key=lambda x: x[1])\n\ncursor_p = 1\ncurrent = 0\ncity = None\nfor py in py_list:\n p = py[0]\n y = py[1]\n\n if p == cursor_p:\n current += 1\n elif p > cursor_p:\n current = 1\n cursor_p = p\n city = str(current).zfill(6)\n pref = str(cursor_p).zfill(6)\n\n print(pref+city)\n', '# WIP\nimport sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\n\npy_list = \\\n [list(map(int, input().split()))+[i] for i, m in enumerate(range(m))]\npy_list.sort(key=lambda x: x[1])\n\ncursor_p = 1\ncurrents = [0] * n\ncity = None\naddresses = []\nfor py in py_list:\n p = py[0]\n y = py[1]\n idx = py[2]\n\n if p == cursor_p:\n currents[cursor_p - 1] += 1\n else:\n cursor_p = p\n currents[cursor_p - 1] += 1\n city = str(currents[cursor_p - 1]).zfill(6)\n pref = str(cursor_p).zfill(6)\n\n addresses.append((idx, pref + city))\n\naddresses.sort(key=lambda x: x[0])\n\nfor address in addresses:\n print(address[1])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s825812747', 's906597227', 's918651338']
[23308.0, 18220.0, 39052.0]
[428.0, 378.0, 592.0]
[473, 451, 656]
p03221
u934868410
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 a,b = map(int, input().split())\n py.append([a,b,i])\npy.sort()\nprint(py)\np = py[0][0]\ny = 1\nfor i in range(m):\n if py[i][0] == p:\n py[i][1] = y\n y += 1\n else:\n py[i][1] = 1\n y = 1\n p = py[i][0]\npy = sorted(py, key=lambda x:x[2])\nfor p,y,i in py:\n print("{:0=6}{:0=6}".format(p,y))\n', 'n,m = map(int, input().split())\npy = []\nfor i in rante(m):\n a,b = map(int, input.split())\n py.append([a,b,i])\npy.sort()\np = 1\ny = 1\nfor i in range(m):\n if py[i][0] == p:\n py[i][1] = y\n y += 1\n else:\n py[i][1] = 1\n y = 1\n p = py[i][0]\npy = sorted(py, key=lambda x:x[2])\nfor p,y,i in py:\n print("{06}{06}".format(p,y))\n\n', 'n,m = map(int, input().split())\npy = []\nfor i in rante(m):\n a,b = map(int, input.split())\n py.append([a,b,i])\npy.sort()\np = 1\ny = 1\nfor i in range(m):\n if py[i][0] == p:\n py[i][1] = y\n y += 1\n else:\n py[i][1] = 1\n y = 1\n p = py[i][0]\npy.sort(key=lambda x:x[2])\nfor p,y,i in py:\n print("{06}{06}".format(p,y))\n\n', 'n,m = map(int, input().split())\npy = []\nfor i in range(m):\n a,b = map(int, input().split())\n py.append([a,b,i])\npy.sort()\np = py[0][0]\ny = 1\nfor i in range(m):\n if py[i][0] == p:\n py[i][1] = y\n y += 1\n else:\n py[i][1] = 1\n y = 2\n p = py[i][0]\npy = sorted(py, key=lambda x:x[2])\nfor p,y,i in py:\n print("{:0=6}{:0=6}".format(p,y))\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s041209170', 's414412922', 's793259473', 's320381787']
[31288.0, 3064.0, 3064.0, 25520.0]
[796.0, 17.0, 18.0, 751.0]
[360, 338, 330, 350]
p03221
u937706062
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 = [None] * M\nfor i in range(M):\n\tp, y = map(int, input().split())\n\tl[i] = [p, y, i]\nl.sort()\nans = []\nt = l[0][0]\nx = 0\nfor i in l:\n\tif t == i[0]:\n\t\tx += 1\n\t\tans.append([l[2], i[0], x])\n\telse:\n\t\tt = i[0]\n\t\tx = 1\n\t\tans.append([l[2], i[0], x])\nans.sort()\nfor i in ans:\n\tp = str(i[1])\n\tx = str(i[2])\n\tprint('0' * (6 - len(p)) + p + '0' * (6 - len(x)) + x)", "N, M = map(int, input().split())\nl = [None] * M\nfor i in range(M):\n\tp, y = map(int, input().split())\n\tl[i] = [p, y, i]\nl.sort()\nans = []\nt = l[0][0]\nx = 0\nfor i in l:\n\tif t == i[0]:\n\t\tx += 1\n\t\tans.append([i[2], i[0], x])\n\telse:\n\t\tt = i[0]\n\t\tx = 1\n\t\tans.append([i[2], i[0], x])\nans.sort()\nfor i in ans:\n\tp = str(i[1])\n\tx = str(i[2])\n\tprint('0' * (6 - len(p)) + p + '0' * (6 - len(x)) + x)"]
['Runtime Error', 'Accepted']
['s547229939', 's013545443']
[37564.0, 37820.0]
[764.0, 852.0]
[387, 387]
p03221
u940102677
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())\nd = [[]]*(n+1)\nq = [[]]*(n+1)\np = [0]*m\ny = [0]*m\nfor i in range(m):\n p[i], y[i] = map(int,input().split())\n d[p[i]] = d[p[i]] + [y[i]]\nfor i in range(n+1):\n if len(d[i]) == 0:\n continue\n d[i] = sorted(d[i])\n d[i] = dict([[d[i][j],j] for j in range(len(d[i]))])\nprint(d)\nfor i in range(m):\n print("{0:06d}".format(p[i])+"{0:06d}".format(d[p[i]][y[i]]+1))', 'n,m = map(int,input().split())\nd = dict()\np = [0]*m\ny = [0]*m\nc = [0]*m\na = []\nfor i in range(m):\n p[i], y[i] = map(int,input().split())\n a.append([y[i], i, p[i]])\na.sort()\nfor x in a:\n if x[2] in d:\n d[x[2]] = d[x[2]] + 1\n else:\n d[x[2]] = 1\n c[x[1]] = d[x[2]]\nfor i in range(m):\n print("{0:06d}".format(p[i])+"{0:06d}".format(c[i]))\n']
['Wrong Answer', 'Accepted']
['s442115063', 's300664498']
[47468.0, 34492.0]
[2104.0, 741.0]
[394, 348]
p03221
u940743763
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, attrgetter\n\nn, m = list(map(int, input().split(' ')))\n\npym = [None] * m\nfor i in range(m):\n pym[i] = [i] + list(map(int, input().split(' ')))\n\npyms = sorted(pym, key=itemgetter(1, 2))\n\nx = 1\npyms[0].append(x)\n\nfor i in range(1, m):\n if pyms[i - 1][1] != pyms[i][1]:\n x = 1\n else:\n x += 1\n pyms[i].append(x)\n \npym = sorted(pyms, key=itemgetter(0, ))\n\nfor i in range(m):\n city_id = str(pym[i][1]).zfill(8) + str(pym[i][3]).zfill(8)\n print(city_id)\n", "from operator import itemgetter, attrgetter\n\nn, m = list(map(int, input().split(' ')))\n\npym = [None] * m\nfor i in range(m):\n pym[i] = [i] + list(map(int, input().split(' ')))\n\npyms = sorted(pym, key=itemgetter(1, 2))\n\nx = 1\npyms[0].append(x)\n\nfor i in range(1, m):\n if pyms[i - 1][1] != pyms[i][1]:\n x = 1\n else:\n x += 1\n pyms[i].append(x)\n \npym = sorted(pyms, key=itemgetter(0, ))\n\nfor i in range(m):\n city_id = str(pym[i][1]).zfill(6) + str(pym[i][3]).zfill(6)\n print(city_id)\n"]
['Wrong Answer', 'Accepted']
['s856339344', 's041737359']
[37512.0, 37512.0]
[847.0, 871.0]
[514, 514]
p03221
u942915776
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())\npys = [list(map(int, input().split())) for _ in range(m)]\nmap_ = {}\nfor i, (p, y) in enumerate(pys):\n map_.setdefault(p, [])\n map_[p].append(i)\nfor val in map_.values():\n val.sort()\n\nans = [None] * m\nfor key, val in map_.items():\n for num, i in enumerate(val):\n ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)\nfor a in ans:\n print(a)\n", "n, m = map(int, input().split())\npys = [list(map(int, input().split())) for _ in range(m)]\nmap_ = {}\nfor i, (p, y) in enumerate(pys):\n map_.setdefault(p, [])\n map_[p].append(i)\n\nfor val in map_.values():\n val.sort(key=lambda i: pys[i][1])\n\nans = [None] * m\nfor key, val in map_.items():\n for num, i in enumerate(val):\n ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)\nfor a in ans:\n print(a)\n"]
['Wrong Answer', 'Accepted']
['s622835658', 's241863355']
[51472.0, 51472.0]
[712.0, 770.0]
[398, 422]
p03221
u951480280
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)]\nI=[]\nfor i in range(m):\n p,y=map(int,input().split())\n A[p].append([i,y])\nfor i in range(n+1):\n if A[i] != []:\n for j in range(len(A[i])):\n I.append([A[i][j] ,str(i).zfill(6) ,str(j+1).zfill(6)])\nI.sort(key=lambda x: x[0])\nfor i in range(len(I)):print(I[i][1],I[i][2],sep="")', 'n,m=map(int,input().split())\nA=[[] for i in range(n+1)]\nI=[]\nfor i in range(m):\n p,y=map(int,input().split())\n A[p].append([i,y])\n\nprint(A)\n\nfor i in range(n+1):\n if A[i] != []:\n for j in range(len(A[i])):\n I.append([A[i][j][0] ,str(i).zfill(6) ,str(j+1).zfill(6)])\nI.sort(key=lambda x: x[0])\nfor i in range(len(I)):print(I[i][1],I[i][2],sep="")', 'n,m=map(int,input().split())\nA=[[] for i in range(n+1)]\nI=[]\nfor i in range(m):\n p,y=map(int,input().split())\n A[p].append(y)\nprint(A)\nfor i in range(n+1):\n if A[i] != []:\n for j in range(len(A[i])):\n I.append([str(i).zfill(6) ,str(j+1).zfill(6)])\nI.sort(key=lambda x: x[1])\nfor i in range(len(I)):print("".join(I[i]))', 'n,m=map(int,input().split())\nA=[[] for i in range(n+1)]\nI=[]\nfor i in range(m):\n p,y=map(int,input().split())\n A[p].append([i,y])\n\nfor i in range(n+1):A[i].sort(key=lambda x: x[1])\n\nfor i in range(n+1):\n if A[i] != []:\n for j in range(len(A[i])):\n I.append([A[i][j][0] ,str(i).zfill(6) ,str(j+1).zfill(6)])\nI.sort(key=lambda x: x[0])\nfor i in range(len(I)):print(I[i][1],I[i][2],sep="")']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s134567858', 's241818314', 's263864127', 's779446784']
[53528.0, 57388.0, 43076.0, 53568.0]
[1080.0, 1101.0, 696.0, 1118.0]
[358, 372, 345, 413]
p03221
u951592041
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.
['#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n"""Describe\n"""\nimport numpy as np\nfrom operator import itemgetter\n\ndef main():\n n, m = map(int, input().split())\n data = None\n for i in range(m):\n p, y = map(int, input().split())\n if data is None:\n data = np.array([[p, y]])\n else:\n data = np.append(data, [[p, y]], axis=0)\n # print(np.array(data)) \n data = data.tolist()# np.transpose(data).tolist()\n data = sorted(data, key=itemgetter(0, 1))\n # print(data)\n\n p, y = 0, 0\n p_prev = 0 \n x = 1 # initialize\n for p, y in data:\n # initialize if new prefecture, increment if not\n if p != p_prev:\n x = 1\n else:\n x += 1\n code = \'{:06d}{:06d}\'.format(p, x)\n print(code) \n p_prev = p\n \n \n\n# print(np.array(data))\n# dtypes = np.dtype([(\'p\', \'int\'), (\'y\', \'int\')])\n# data = np.array(data, dtype=dtypes)\n\n# print(i, data[i])\n# for j in range(len(data[i])):\n# print(data[i][j])\n# \nmain()\n', '#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n"""Describe\n"""\nfrom operator import itemgetter\n\ndef main():\n n, m = map(int, input().split())\n data = []\n for i in range(m):\n p, y = map(int, input().split())\n data.append([p, y, i])\n # print(data)\n data_sorted = sorted(data, key=itemgetter(0, 1))\n \n\n p, y, i = 0, 0, 0\n p_prev = 0 \n x = 1 # initialize\n codes = []\n for p, y, i in data_sorted:\n # initialize if new prefecture, increment if not\n if p != p_prev:\n x = 1\n else:\n x += 1\n code = \'{:06d}{:06d}\'.format(p, x)\n codes.append([i, code])\n p_prev = p\n # print(codes)\n\n codes_sorted = sorted(codes, key=itemgetter(0))\n \n\n for i, code in codes_sorted:\n print(code)\n \nmain()\n']
['Wrong Answer', 'Accepted']
['s004380007', 's514303193']
[14532.0, 42976.0]
[2109.0, 724.0]
[1100, 853]
p03221
u960080897
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; from decimal import Decimal\nimport math; from itertools import combinations, product\nimport bisect; from collections import Counter, deque, defaultdict\n\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 9\nPI = 3.14159265358979323846\n\ndef read_str(): return sys.stdin.readline().strip()\ndef read_int(): return int(sys.stdin.readline().strip())\ndef read_ints(): return map(int, sys.stdin.readline().strip().split())\ndef read_str_list(): return list(sys.stdin.readline().strip().split())\ndef read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))\ndef lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)\n\ndef Main():\n n, m = read_ints()\n py = []\n for i in range(m):\n p, y = read_ints()\n py.append([y, p, i])\n py.sort(key=lambda x: x[0]) \n cnt = [0] * n\n \n for year, prefecture, idx in py:\n cnt[prefecture - 1] += 1\n print(f'{prefecture:06d}{cnt[prefecture-1]:06d}')\n\nif __name__ == '__main__':\n Main()", "import sys; from decimal import Decimal\nimport math; from itertools import combinations, product\nimport bisect; from collections import Counter, deque, defaultdict\n\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 9\nPI = 3.14159265358979323846\n\ndef read_str(): return sys.stdin.readline().strip()\ndef read_int(): return int(sys.stdin.readline().strip())\ndef read_ints(): return map(int, sys.stdin.readline().strip().split())\ndef read_str_list(): return list(sys.stdin.readline().strip().split())\ndef read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))\ndef lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)\n\ndef Main():\n n, m = read_ints()\n py = []\n for i in range(m):\n p, y = read_ints()\n py.append([y, p, i])\n py.sort(key=lambda x: x[0]) \n cnt = [0] * n\n ans = [''] * m\n \n for year, prefecture, idx in py:\n cnt[prefecture - 1] += 1\n ans[idx] = f'{prefecture:06d}{cnt[prefecture-1]:06d}'\n\n print(*ans, sep='\\n') \n\nif __name__ == '__main__':\n Main()"]
['Wrong Answer', 'Accepted']
['s560818611', 's612721427']
[31092.0, 38912.0]
[281.0, 290.0]
[1032, 1090]
p03221
u961683878
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\n\nn, m = list(map(int, input().split()))\nmat = np.zeros((m, 2))\nfor i in range(m):\n\tmat[i, 0], mat[i, 1] = list(map(int, input().split()))\nmat = np.c_[mat, np.array(range(m))]\nmat = mat[mat[:, 1].argsort()]\ncnt = np.zeros(m)\nres = []\nprint(cnt[2])\nfor i, j in mat[:, :2]:\n\ti = int(i)\n\tcnt[i] += 1\n\tres.append('{0:06d}{1:06d}'.format(i, int(cnt[i])))\n#print(res)\n#print(list(mat_[:, 2]))\nfor i in np.argsort(mat[:, 2]):\n\tprint(res[int(i)])\n#res_ = res[np.argsort(mat_[:, 2])]\n#for r in res_:\n#\tprint(r)\t\n", "import numpy as np\n\nn, m = list(map(int, input().split()))\nmat = np.zeros((m, 2))\nfor i in range(m):\n\tmat[i, 0], mat[i, 1] = list(map(int, input().split()))\nmat = np.c_[mat, np.array(range(m))]\nmat = mat[mat[:, 1].argsort()]\ncnt = np.zeros(m)\nres = []\nfor i, in mat[:, 0]:\n\ti = int(i)\n\tcnt[i] += 1\n\tres.append('{0:06d}{1:06d}'.format(i, int(cnt[i])))\n\nfor i in np.argsort(mat[:, 2]):\n\tprint(res[int(i)])\n", "import numpy as np\n\nn, m = list(map(int, input().split()))\nmat = np.zeros((m, 3))\nfor i in range(m):\n\tmat[i, 0], mat[i, 1] = list(map(int, input().split()))\n\tmat[i, 2] = i\nmat = mat[mat[:, 1].argsort()]\ncnt = np.zeros(n+1)\nres = []\nfor i in mat[:, 0]:\n\ti = int(i)\n\tcnt[i-1] += 1\n\tres.append('{0:06d}{1:06d}'.format(i, int(cnt[i-1])))\n\nfor idx in np.argsort(mat[:, 2]):\n\tprint(res[int(idx)])\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s615369937', 's760942175', 's196012424']
[25972.0, 19480.0, 27832.0]
[1181.0, 615.0, 1075.0]
[521, 404, 391]
p03221
u962197874
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 l.append(list(map(int,input().split())))\nl.sort()\np = 0\nfor i in l:\n if i[0] != p:\n p = i[0]\n x = 1\n else:\n x += 1\n print(str(i[0]).zfill(6)+ str(x).zfill(6))', 'import numpy as np\nn, m = map(int,input().split())\nl = [list(map(int,input().split()))+ [0] for i in range(m)]\nl2 = sorted(l)\np = 0\nfor i in l2:\n x = 1 if i[0] != p else x + 1\n p = i[0]\n i[2] = x\nfor i in l:\n print(str(i[0]).zfill(6)+str(i[2]).zfill(6))']
['Wrong Answer', 'Accepted']
['s961001428', 's572005778']
[28804.0, 34344.0]
[806.0, 875.0]
[250, 265]
p03221
u966408025
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\nms = [0]*m\nfor i in range(m):\n p, y = [int(x) for x in input().split()]\n ms[i] = (p, y)\n\nsorted_ms = sorted(ms, key=lambda x: x[1])\nps = [[]] * n\nfor i in range(n):\n result = list(filter(lambda x: x[0] == i+1, ms))\n ps[i] = result\n\nfor i in range(m):\n for j, x in enumerate(ps[ms[i][0] - 1]):\n if x[1] == ms[i][1]:\n print('%s%s' % (str(ms[i][0]).zfill(6), str(j+1).zfill(6)))\n", "n, m = [int(x) for x in input().split()]\n\nms = []\nfor i in range(m):\n p, y = [int(x) for x in input().split()]\n ms.append({\n 'p': p,\n 'y': y\n })\n\nsorted_ms = sorted(ms, key=lambda x: x.get('y'))\nps = []\nfor i in range(n):\n result = list(filter(lambda x: x.get('p') == i+1, ms))\n ps.append(result)\n\nfor i in range(m):\n for j, x in enumerate(ps[ms[i].get('p') - 1]):\n if x.get('y') == ms[i].get('y'):\n print('%s%s' % (str(ms[i].get('p')).zfill(6), str(j+1).zfill(6)))\n", 'n, m = [int(x) for x in input().split()]\n\nps = [[] for i in range(n)]\nfor i in range(m):\n p, y = [int(x) for x in input().split()]\n ps[p-1].append((y, i))\n\nres = [None] * m\nfor i, ms in enumerate(ps):\n ms.sort()\n for j, x in enumerate(ms):\n res[x[1]] = str(i+1).zfill(6) + str(j+1).zfill(6)\n\nfor i in range(m):\n print(res[i])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s740448029', 's951731835', 's196512311']
[20980.0, 42704.0, 36000.0]
[2109.0, 2106.0, 680.0]
[451, 516, 348]
p03221
u970197315
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 = []\n\nfor i in range(M):\n p,y = map(str,input().split())\n s = "0"*(6-len(p)) + p + "0"*(10-len(y)) + y\n S.append(s)\n\nS.sort()\n\nfor i in range(M):\n l = str(i+1)\n S[i] = S[i][:6] + "0"*(6-len(l)) + l\n print(S[i])\n', 'N,M = map(int,input().split())\nS = []\n\nfor i in range(M):\n p,y = map(str,input().split())\n s = "0"*(6-len(p)) + p + "0"*(6-len(y)) + y\n S.append(s)\n\nS.sort()\n\nfor i in range(M):\n l = str(i+1)\n S[i] = S[i][:6] + "0"*(6-len(l)) + l\n print(S[i])\n', 'n, m = map(int, input().readline().split())\npy = []\nfor _ in range(m):\n py.append(list(map(int,input().split())) + [0])\n\nsortPy = sorted(py, key = lambda x : (x[0], x[1]))\n \nd = {}\nfor i, (p, y, n) in enumerate(sortPy):\n if p in d:\n d[p] += 1\n else:\n d[p] = 1\n sortPy[i][2] = d[p]\n \nfor p, y, n in py:\n print(str(p).zfill(6) + str(n).zfill(6))', 'n, m = map(int, stdin.readline().split())\npy = []\nfor _ in range(m):\n py.append(list(map(int, stdin.readline().split())) + [0])\n\nsortPy = sorted(py, key = lambda x : (x[0], x[1]))\n \nd = {}\nfor i, (p, y, n) in enumerate(sortPy):\n if p in d:\n d[p] += 1\n else:\n d[p] = 1\n sortPy[i][2] = d[p]\n\nfor p, y, n in py:\n print(str(p).zfill(6) + str(n).zfill(6))', 'N,M = map(int,input().split())\nS = []\nd = {}\n\nfor i in range(M):\n p,y = map(str,input().split())\n s = "0"*(6-len(p)) + p + "0"*(10-len(y)) + y\n S.append(s)\n\nfor i in range(M):\n l = str(i+1)\n s = S[i][:6]\n if s in d:\n d[s] += 1\n else:\n d[s] = 0\n S[i] = s + "0"*(6-len(l)) + str(d[s]+1)\n print(S[i])\n', "# ID\nn,m=map(int,input().split())\ns=[[] for _ in range(n)]\nfor i in range(m):\n p,y=map(int,input().split())\n s[p-1].append([y,i])\n\nfor i in range(len(s)):\n s[i].sort()\n\nans=[]\nfor i,ss in enumerate(s):\n for j,sss in enumerate(ss):\n id_no=''\n id_no+='0'*(6-len(str(i+1)))+str(i+1)\n id_no+='0'*(6-len(str(j+1)))+str(j+1)\n s[i][j].append(id_no)\n\nfor i,ss in enumerate(s):\n for j,sss in enumerate(ss):\n ans.append(s[i][j])\nans.sort(key=lambda x:x[1])\nfor aa in ans:\n print(aa[2])\n\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s012832522', 's620801395', 's622690002', 's640587445', 's664405695', 's945528117']
[18236.0, 11680.0, 3064.0, 3064.0, 25220.0, 45488.0]
[553.0, 549.0, 17.0, 18.0, 577.0, 967.0]
[262, 261, 354, 361, 339, 530]
p03221
u970899068
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=[list(map(int, input().split())) for i in range(m)] \nfor i in range(m):\n s[i].append(i+1)\nprint(s)\na=0\ns.sort()\nfor i in range(m):\n if i>1:\n if s[i][0]!=s[i-1][0]:\n a=0\n \n s[i].append(str(0)*(6-len(str(s[i][0])))+str(s[i][0]))\n s[i].append(str(0)*(6-len(str(a)))+str(a+1))\n a+=1\ns.sort(key=lambda x:x[2])\nfor i in range(m):\n print(s[i][3]+s[i][4])', 'n,m=map(int,input().split())\ns=[list(map(int, input().split())) for i in range(m)] \nfor i in range(m):\n s[i].append(i+1)\na=0\ns.sort()\nfor i in range(m):\n if i>=1:\n if s[i][0]!=s[i-1][0]:\n a=0\n \n s[i].append(str(0)*(6-len(str(s[i][0])))+str(s[i][0]))\n s[i].append(str(0)*(6-len(str(a+1)))+str(a+1))\n a+=1\ns.sort(key=lambda x:x[2])\nfor i in range(m):\n print(s[i][3]+s[i][4])\n']
['Wrong Answer', 'Accepted']
['s865199638', 's859146756']
[47240.0, 43632.0]
[966.0, 911.0]
[421, 416]
p03221
u971091945
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 = []\nmli = [0]*m\nli = [""]*m\n\nfor i in range(m):\n p,y = map(int, input().split())\n py.append([p,y,i])\n\npy.sort(key=lambda x: x[1])\n\nfor p,y,i in py:\n mli[p] += 1\n pi = \'{0:05d}\'.format(p)\n yi = \'{0:05d}\'.format(mli[p])\n li[i] = str(pi)+str(yi)\n\nfor i in li:\n print(i)', 'n, m = map(int, input().split())\npy = []\nmli = [0]*n\nli = [""]*m\n\nfor i in range(m):\n p,y = map(int, input().split())\n py.append([p,y,i])\n\npy.sort(key=lambda x: x[1])\n\nfor p,y,i in py:\n mli[p-1] += 1\n pi = str(p).zfill(6)\n yi = str(mli[p-1]).zfill(6)\n li[i] = pi+yi\n\nfor i in li:\n print(i)']
['Runtime Error', 'Accepted']
['s079396931', 's172014041']
[32000.0, 32176.0]
[667.0, 636.0]
[324, 310]
p03221
u973840923
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())\nlist = [[] for i in range(N)]\n\nfor i in range(M):\n j,k = map(int,input().split())\n list[j-1].append((k,i))\n\nans = [None]*M\n\nfor i,j in enumerate(list):\n j.sort()\n for k,(l,m) in enumerate(j):\n ans[m] = "%06d%06d" % (i+1,k+1)\n\nprint(ans)\n', "N,M = map(int,input().split())\nlist = [list(map(int,input().split())) for _ in range(M)]\nlist_pre = [[] for _ in range(N)]\n\nfor i,l in enumerate(list):\n list_pre[l[0]-1].append([l[1],i])\n\nans = []\n\nfor i,l in enumerate(list_pre):\n l.sort()\n for j,l2 in enumerate(l):\n ans.append([i+1,j+1,l2[1]])\n\nans.sort(key=lambda x:x[2])\n\nfor l in ans:\n print('%06d%06d' % (l[0],l[1]))"]
['Wrong Answer', 'Accepted']
['s513368042', 's984405087']
[39268.0, 61552.0]
[544.0, 922.0]
[287, 391]
p03221
u977389981
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())\nipy = []\n\nfor i in range(m):\n p, y = map(int, input().split())\n ipy.append([i, p, y])\n \nipy = sorted(ipy, key=lambda x: x[2])\n\ncount = {}\norder = {}\n\nfor i, p, y in ipy:\n if not p in count:\n count[p] = 1\n else:\n count[p] += 1\n order[i, p] = count[p]\n \nfor i, p, y in ipy:\n print('{:06}{:06}'.format(i, order[i, p]))", "n, m = map(int, input().split())\nipy = []\n\nfor i in range(m):\n p, y = map(int, input().split())\n ipy.append([i, p, y])\n\ncounter = {}\norder = {}\n\nfor i, p, y in sorted(ipy, key = lambda x: x[2]):\n counter[p] = counter.get(p, 0) + 1\n order[i, p] = counter[p]\n \nfor i, p, y in ipy:\n print('{:06}{:06}'.format(p, order[i, p]))"]
['Wrong Answer', 'Accepted']
['s722692888', 's061633155']
[43696.0, 44484.0]
[819.0, 671.0]
[386, 340]
p03221
u978313283
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+1)]\nY=[]\nid=[]\nfor i in range(M):\n a,b=map(int,input().split())\n P[a].append(b)\n Y.append(b)\nfor i in range(N+1):\n P[i].sort()\nfor i in range(1,N+1):\n j=1\n for p in P[i]:\n id[Y.index(p)]=str(i*1000000+j)\n j+=1\nfor i in range(M):\n print(id[i].zfill(12))\n', 'N,M=map(int,input().split())\nP=[[] for i in range(M)]\nY=[1 for i in range(N+1)]\nfor i in range(M):\n a,b=map(int,input().split())\n P[i].append(i)\n P[i].append(a)\n P[i].append(b)\nP.sort(key=lambda x:x[2])\nfor i in range(M):\n P[i].append(str(P[i][1]*1000000+Y[P[i][1]]))\n Y[P[i][1]]+=1\nP.sort(key=lambda x:x[0])\nfor i in range(M):\n print(P[i][3].zfill(12))\n\n']
['Runtime Error', 'Accepted']
['s014568509', 's239527922']
[18712.0, 33024.0]
[380.0, 779.0]
[340, 376]
p03221
u981931040
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())\nbirth = []\nfor i in range(M):\n a , b = map(int,input().split())\n birth.append([a,b,i])\nprint(birth)\nwork_list = sorted(birth,key=lambda x: x[1])\nwork_list.sort()\n#print(birth)\nupper = 1\nlower = 1\nans = []\nfor i in range(1,len(birth)):\n ans.append([work_list[i-1][2],str(work_list[i-1][0]).zfill(6) + str(lower).zfill(6)])\n if work_list[i][0] == work_list[i-1][0]:\n lower += 1\n else:\n lower = 1\n upper += 1\nans.append([work_list[M - 1][2],str(work_list[M-1][0]).zfill(6) + str(lower).zfill(6)])\nans.sort()\nfor val in ans:\n print(val[1])\n', 'N , M = map(int,input().split())\nbirth = []\nfor i in range(M):\n a , b = map(int,input().split())\n birth.append([a,b,i])\n#print(birth)\nwork_list = sorted(birth,key=lambda x: x[1])\nwork_list.sort()\n#print(birth)\nlower = 1\nans = []\nfor i in range(1,len(birth)):\n ans.append([work_list[i-1][2],str(work_list[i-1][0]).zfill(6) + str(lower).zfill(6)])\n if work_list[i][0] == work_list[i-1][0]:\n lower += 1\n else:\n lower = 1\nans.append([work_list[M - 1][2],str(work_list[M-1][0]).zfill(6) + str(lower).zfill(6)])\nans.sort()\nfor val in ans:\n print(val[1])']
['Wrong Answer', 'Accepted']
['s193678995', 's181552950']
[44632.0, 41904.0]
[1048.0, 1019.0]
[608, 579]
p03221
u984664611
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\n\ndef main():\n n, m = map(int, input().split())\n ans_id = [None]*m\n p_count = [0]*(n+1)\n\n list_ipy = [None]*m\n for i in range(m):\n p, y = map(int, input().split())\n list_ipy[i] = (i, p, y)\n list_ipy.sort(key=lambda x: x[2])\n\n for ipy in list_ipy:\n i, p, _ = ipy\n p_count[p] += 1\n first = format(p, '06')\n second = format(p_count[p], '08')\n ans_id[i] = first + second\n\n for id in ans_id:\n print(id)\n\n\nif __name__ == '__main__':\n main()\n", "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n, m = map(int, input().split())\n ans_id = [None]*m\n p_count = [0]*(n+1)\n\n list_ipy = [None]*m\n for i in range(m):\n p, y = map(int, input().split())\n list_ipy[i] = (i, p, y)\n list_ipy.sort(key=lambda x: x[2])\n\n for ipy in list_ipy:\n i, p, _ = ipy\n p_count[p] += 1\n first = format(p, '06')\n second = format(p_count[p], '06')\n ans_id[i] = first + second\n\n for id in ans_id:\n print(id)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s363026461', 's524659374']
[30028.0, 29852.0]
[380.0, 410.0]
[556, 556]
p03221
u987164499
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 sys import stdin\nimport bisect\n\nn,m = [int(x) for x in stdin.readline().rstrip().split()]\nli = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]\n\nlin = [[]for i in range(n)]\nlin2 = []\nli3 = []\nfor j in range(m):\n lin[li[j][0]-1].append(li[j][1])\n lin2.append(li[j][0]-1)\n\nfor j in range(n):\n liv = sorted(lin[j])\n li3.append(liv)\n\nfor k in range(m):\n s = len(str(li[k][1]))\n v = len(str(li[j][0]))\n print("0"*(6-v)+str(li[k][0])+"0"*(6-s)+str(bisect.bisect(li3[li[k][0]-1],li[k][1])))', 'from sys import stdin\nimport bisect\n\nn,m = [int(x) for x in stdin.readline().rstrip().split()]\nli = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]\n\nlin = [[]for _ in range(n)]\nlin2 = []\nfor i in range(m):\n lin[li[j][0]-1].append(li[i][1])\n\nfor j in range(n):\n liv = sorted(lin[j])\n lin2.append(liv)\n\nfor k in range(m):\n tosi = str(li[k][0]).zfill(6)\n ban = str(bisect.bisect(lin2[li[k][0]-1],li[k][1])).zfill(6)\n print(tosi+ban)', 'import bisect\n\nn,m = map(int,input().split())\n\nli = [[] for _ in range(n+1)]\nnum = []\n\nfor _ in range(m):\n p,y = map(int,input().split())\n li[p].append(y)\n num.append((p,y))\n\nfor i in range(n+1):\n li[i].sort()\n\nfor i,j in num:\n print(str(i).zfill(6)+str(bisect.bisect_left(li[i],j)+1).zfill(6))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s163106860', 's793146195', 's127741584']
[51164.0, 34684.0, 32952.0]
[720.0, 217.0, 414.0]
[529, 469, 309]
p03221
u987170100
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())\nkv = {}\nlst = []\nfor _ in range(M):\n x, y = map(int, input().split())\n lst.append("{0} {1}".format(x, y))\n if x in kv:\n kv[x][y] = 1\n else:\n kv[x] = {y:1}\n\nfor k1 in sorted(kv.keys()):\n keys = sorted(kv[k1].keys())\n for idx, k2 in enumerate(keys, 1):\n kv[k1][k2] = idx\n\nprint(kv)\nfor s in lst:\n x, y = map(int, s.split())\n print("{0:06d}{1:06d}".format(x,kv[x][y]))', 'N, M = map(int, input().split())\nkv = {}\nlst = []\nfor _ in range(M):\n x, y = map(int, input().split())\n lst.append("{0} {1}".format(x, y))\n if x in kv:\n kv[x][y] = 1\n else:\n kv[x] = {y:1}\n\nfor k1 in sorted(kv.keys()):\n keys = sorted(kv[k1].keys())\n for idx, k2 in enumerate(keys, 1):\n kv[k1][k2] = idx\n\nfor s in lst:\n x, y = map(int, s.split())\n print("{0:06d}{1:06d}".format(x,kv[x][y]))']
['Wrong Answer', 'Accepted']
['s397691394', 's951046066']
[60236.0, 54348.0]
[1201.0, 993.0]
[443, 433]
p03221
u990726146
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 = [0] * M\nfor i in range(M):\n P[i] = list(map(int, input().split())) + [i + 1]\n\nP = sorted(P, key = lambda x: x[1])\nP = sorted(P, key = lambda x: x[0])\n\na = P[0][0]\nc = 0\nfor i in range(M):\n #print(P[i])\n if P[i][0] == a:\n c += 1\n P[i].append(c)\n else:\n c = 1\n a = P[i][0]\n P[i].append(c)\n print(P[i])\n\nP = sorted(P, key = lambda x: x[2])\nfor i in range(M):\n s = str(P[i][0]).zfill(6)\n ss = str(P[i][3]).zfill(6)\n print(s + ss)\n\n\n', 'N, M = map(int, input().split())\nP = [0] * M\nfor i in range(M):\n P[i] = list(map(int, input().split())) + [i + 1]\n\nP = sorted(P, key = lambda x: x[1])\nP = sorted(P, key = lambda x: x[0])\n\na = P[0][0]\nc = 0\nfor i in range(M):\n #print(P[i])\n if P[i][0] == a:\n c += 1\n P[i].append(c)\n else:\n c = 1\n a = P[i][0]\n P[i].append(c)\n #print(P[i])\n\nP = sorted(P, key = lambda x: x[2])\nfor i in range(M):\n s = str(P[i][0]).zfill(6)\n ss = str(P[i][3]).zfill(6)\n print(s + ss)\n\n\n']
['Wrong Answer', 'Accepted']
['s831088341', 's697348031']
[37300.0, 37412.0]
[626.0, 531.0]
[524, 525]
p03221
u991567869
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 = []\n\nfor i in range(m):\n p, y = input().split()\n l.append([p, y])\n\nl.sort()\n\nl[0][1] = 1\n\nfor i in range(1, m):\n if l[i][0] == l[i - 1][0]:\n l[i][1] = l[i - 1][1] + 1\n else:\n l[i][1] = 1\n\nfor i in l:\n ans = "0"*(6 - len(i[0])) + i[0] + "0"*(6 - len(str(i[1]))) + str(i[1])\n print(ans)', 'n, m = map(int, input().split())\nl = []\n\nfor i in range(m):\n p, y = input().split()\n l.append([p, y, m])\n\nl.sort()\n\nl[0][1] = 1\n\nfor i in range(1, m):\n if l[i][0] == l[i - 1][0]:\n l[i][1] = l[i - 1][1] + 1\n else:\n l[i][1] = 1\n\nsortthird = lambda val: val[2]\nl.sort(key = sortthird)\n\n\nfor i in l:\n ans = "0"*(6 - len(i[0])) + i[0] + "0"*(6 - len(str(i[1]))) + str(i[1])\n print(ans)', 'n, m = map(int, input().split())\npy = [list(map(int, input().split())) for i in range(m)]\nc = [0]*(n + 1)\nid = {}\n\nfor p, y in sorted(py, key = lambda x: x[1]):\n c[p] += 1\n id[y] = format(p, "06") + format(c[p], "06")\n\nfor p, y in py:\n print(id[y])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s126107780', 's642051779', 's499636049']
[29732.0, 29712.0, 43856.0]
[629.0, 710.0, 702.0]
[352, 412, 258]
p03221
u993435350
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\ndef main():\n N,M = map(int,input().split())\n pref = [[] for i in range(N)]\n id = [[]] * M\n \n for i in range(M):\n p,y = map(int,input().split())\n id[i] = [p,y]\n pref[p - 1].append(y)\n \n \n for i in range(N):\n pref[i] = sorted(pref[i])\n \n orders = [0] * N\n \n for i in range(M):\n p = id[i][0] - 1\n y = id[i][1]\n order = str(bisect.bisect_left(pref[p],y) + 1)\n city = str(p + 1)\n ID = ""\n ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order\n print(ID)\n\nif __init__ == \'__main__\':\n main()', 'N,M = map(int,input().split())\npref = [[] for i in range(N)]\nid = [[]] * M\n\nfor i in range(M):\n p,y = map(int,input().split())\n id[i] = [p,y]\n pref[p - 1].append(y)\n \n\nfor i in range(N):\n pref[i] = sorted(pref[i])\n\norders = [0] * N\n\nfor i in range(M):\n p = id[i][0]\n y = id[i][1]\n orders[p - 1] += 1\n order = str(orders[p - 1])\n city = str(p)\n ID = ""\n ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order\n print(ID)', 'import bisect\n\ndef main():\n N,M = map(int,input().split())\n pref = [[] for i in range(N)]\n id = [[]] * M\n \n for i in range(M):\n p,y = map(int,input().split())\n id[i] = [p,y]\n pref[p - 1].append(y)\n \n \n for i in range(N):\n pref[i] = sorted(pref[i])\n \n orders = [0] * N\n \n for i in range(M):\n p = id[i][0] - 1\n y = id[i][1]\n order = str(bisect.bisect_left(pref[p],y) + 1)\n city = str(p + 1)\n ID = ""\n ID += "0" * (6 - len(city)) + city + "0" * (6 - len(order)) + order\n print(ID)\n\nif __name__ == \'__main__\':\n main()']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s654512989', 's721321530', 's370744395']
[3064.0, 33552.0, 33556.0]
[18.0, 687.0, 663.0]
[595, 478, 595]
p03221
u997641430
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())\ndata=[]\nfor m in range(M):\n data.append(list(map(int,input().split())))\n data[m].append(m)\ndata.sort(key=lambda x:x[1])\n\npref=0\nfor m in range(M):\n if data[m][0]!=pref:\n count=1\n ID=('000000'+str(data[m][0]))[-6:]+('000000'+str(count))[-6:]\n data[m].append(ID)\n\ndata.sort(key=lambda x:x[2])\n\nfor m in range(M):\n print(data[m][3])", "N,M=map(int,input().split())\ndata=[]\nfor m in range(M):\n data.append(list(map(int,input().split())))\n data[m].append(m)\ndata.sort(key=lambda x:x[1])\n\npref=0\nfor m in range(M):\n count+=1\n if data[m][0]!=pref:\n count=1\n pref=data[m][0]\n ID=('000000'+str(data[m][0]))[-6:]+('000000'+str(count))[-6:]\n data[m].append(ID)\n\ndata.sort(key=lambda x:x[2])\n\nfor m in range(M):\n print(data[m][3])", "N,M=map(int,input().split())\ndata=[]\nfor m in range(M):\n data.append(list(map(int,input().split())))\n data[m].append(m)\n\ndata.sort(key=lambda x:x[1])\ndata.sort(key=lambda x:x[0])\n\npref=0\ncount=0\nfor m in range(M):\n count+=1\n if data[m][0]!=pref:\n count=1\n pref=data[m][0]\n ID=('000000'+str(data[m][0]))[-6:]+('000000'+str(count))[-6:]\n data[m].append(ID)\n\ndata.sort(key=lambda x:x[2])\n\nfor m in range(M):\n print(data[m][3])"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s147429740', 's626807257', 's614492740']
[40300.0, 32320.0, 38452.0]
[746.0, 453.0, 820.0]
[383, 416, 454]
p03222
u007808656
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['h,w,k=map(int,input().split())\n\ndef amida(h,w,k):\n memo=[[-1 for _ in range(w)] for _ in range(h)]\n memo[0][0]=amida_h1_total(w-1)\n if w>1:\n memo[0][1]=amida_h1_total(w-2)\n for i in range(2,w):\n memo[0][i]=0\n def _amida(h,k):\n if k<=0 or k>w:\n return 0\n if memo[h-1][k-1]>=0:\n return memo[h-1][k-1]\n memo[h-1][k-1]=sum((_amida(h-1,k-1)*amida_h1_total(k-2)*amida_h1_total(w-k),\n _amida(h-1,k) *amida_h1_total(k-1)*amida_h1_total(w-k),\n _amida(h-1,k+1)*amida_h1_total(k-1)*amida_h1_total(w-k-1)))%1000000007\n return memo[h-1][k-1]\n return _amida(h,k)\nprint(amida(h,w,k))', 'h,w,k=map(int,input().split())\ndef amida_h1_total(w):\n if w<0:\n return 0\n if w==0:\n return 1\n return amida_h1_total(w-1)+amida_h1_total(w-2)\ndef amida(h,w,k):\n memo=[[-1 for _ in range(w)] for _ in range(h)]\n memo[0][0]=amida_h1_total(w-1)\n if w>1:\n memo[0][1]=amida_h1_total(w-2)\n for i in range(2,w):\n memo[0][i]=0\n def _amida(h,k):\n if k<=0 or k>w:\n return 0\n if memo[h-1][k-1]>=0:\n return memo[h-1][k-1]\n memo[h-1][k-1]=sum((_amida(h-1,k-1)*amida_h1_total(k-2)*amida_h1_total(w-k),\n _amida(h-1,k) *amida_h1_total(k-1)*amida_h1_total(w-k),\n _amida(h-1,k+1)*amida_h1_total(k-1)*amida_h1_total(w-k-1)))%1000000007\n return memo[h-1][k-1]\n return _amida(h,k)\nprint(amida(h,w,k))\n']
['Runtime Error', 'Accepted']
['s924143327', 's305590204']
[3064.0, 3064.0]
[17.0, 30.0]
[705, 838]
p03222
u026788530
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['H,W,K = [int(i) for i in input().split()]\n\nDP = [[0 for i in range(W)]for j in range(2)]\n\nt = [0 for i in range(W+10)]\n\nt[1] = 1\nt[2] = 2\nfor i in range(2,W+8):\n t[i+1] = t[i] + t[i-1]\n\n#print(t)\nn = 0\nDP[0][0] = 1\nfor i in range(H):\n if W == 1:\n break\n DP[not(n)][0] = (DP[n][0] * t[W-1] + DP[n][1] * t[W-2]) % 1000000007\n for i in range(1,W-1):\n DP[not(n)][i] =( DP[n][i-1] *t[W - (i+1)] + DP[n][i]*(t[i-1] + t[W-i]) + DP[n][i+1]*t[i-2] ) % 1000000007\n \n DP[not(n)][W-1] = (DP[n][W-2]*t[W-2] + DP[n][W-1] * t[W-1]) % 1000000007\n n = not(n)\nprint(DP[n][K])\n', 'H,W,K = [int(i) for i in input().split()]\n\nDP = [[0 for i in range(W)]for j in range(2)]\n\nt = [0 for i in range(W+10)]\nt[0] = 1\nt[1] = 1\nt[2] = 2\nfor i in range(2,W+8):\n t[i+1] = t[i] + t[i-1]\n\n#print(t)\nn = 0\nDP[0][0] = 1\nfor i in range(H):\n if W == 1:\n break\n DP[not(n)][0] = (DP[n][0] * t[W-1] + DP[n][1] * t[W-2]) % 1000000007\n for i in range(1,W-1):\n DP[not(n)][i] =( DP[n][i-1] *(t[W-i-1] * t[i-1]) + DP[n][i] * (t[i] * t[W-i-1]) + DP[n][i+1]*(t[W-i-2] * t[i])) % 1000000007\n \n DP[not(n)][W-1] = (DP[n][W-2]*t[W-2] + DP[n][W-1] * t[W-1]) % 1000000007\n n = not(n)\nprint(DP[n][K-1])\n']
['Runtime Error', 'Accepted']
['s484939818', 's513075688']
[3064.0, 3192.0]
[18.0, 18.0]
[593, 623]
p03222
u057916330
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['def count(length, on):\n """Count of possible amida patterns"""\n if length < 0:\n return 1\n if length == 0:\n return 1\n ret = count(length - 1, False)\n if not on:\n ret += count(length - 1, True)\n return ret\n\n\n\n# print(count(i, True) + count(i, False))\n\n\nif __name__ == \'__main__\':\n H, W, K = map(int, input().split())\n\n # Count\n B = [0 for _ in range(W)]\n B[0] = 1\n for j in range(H):\n C = [0 for _ in range(W)]\n for i in range(W):\n left_off = count(i - 1, False)\n left_on = count(i - 1, True)\n right_off = count(W - i - 2, False)\n right_on = count(W - i - 2, True)\n print(i, left_off, left_on, right_off, right_on)\n\n if B[i] > 0:\n C[i] += B[i] * (left_off * right_off)\n\n if i > 0 and B[i - 1] > 0:\n C[i] += B[i - 1] * (left_on * right_off)\n\n if i < W - 1 and B[i + 1] > 0:\n C[i] += B[i + 1] * (left_off * right_on)\n\n B = [ci for ci in C]\n \n\n MOD = 1_000_000_007\n ANS = C[K - 1] % MOD\n print(ANS)\n', 'def count(length, on):\n """Count of possible amida patterns"""\n if length < 0:\n return 1\n if length == 0:\n return 1\n ret = count(length - 1, False)\n if not on:\n ret += count(length - 1, True)\n return ret\n\n\n\n# print(count(i, True) + count(i, False))\n\n\nif __name__ == \'__main__\':\n H, W, K = map(int, input().split())\n\n # Count\n B = [0 for _ in range(W)]\n B[0] = 1\n for j in range(H):\n C = [0 for _ in range(W)]\n for i in range(W):\n left_off = count(i - 1, False)\n left_on = count(i - 1, True)\n right_off = count(W - i - 2, False)\n right_on = count(W - i - 2, True)\n \n\n if B[i] > 0:\n C[i] += B[i] * (left_off * right_off)\n\n if i > 0 and B[i - 1] > 0:\n C[i] += B[i - 1] * (left_on * right_off)\n\n if i < W - 1 and B[i + 1] > 0:\n C[i] += B[i + 1] * (left_off * right_on)\n\n B = [ci for ci in C]\n \n\n # MOD = 1_000_000_007 # Underscore is not supported until 3.6\n MOD = 1000000007\n ANS = C[K - 1] % MOD\n print(ANS)\n']
['Runtime Error', 'Accepted']
['s679712337', 's841926341']
[3064.0, 3064.0]
[18.0, 25.0]
[1155, 1221]
p03222
u062459048
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['H, W, K = map(int,input().split())\ndp = [[0]*W for _ in range(H+1)]\ndp[0][0] = 1\n\nck = [0]*9\nck[0] = 1\nfor i in range(1,9):\n for j in range(2**(i-1)):\n for k in range(i-1):\n if (j>>k)&(j>>(k+1))==True:\n break\n else:\n ck[i] += 1\nprint(ck)\n\nmod = 10**9+7\nfor i in range(1,H+1):\n for j in range(W):\n if j == 0:\n dp[i][j] = dp[i-1][j]*ck[W-2]+dp[i-1][j+1]*ck[W-3]\n elif j == W-1:\n dp[i][j] = dp[i-1][j]*ck[W-2]+dp[i-1][j-1]*ck[W-3] \n else:\n dp[i][j] = dp[i-1][j+1]*(ck[j-1]+ck[W-j-3])+dp[i-1][j]*(ck[j-1]+ck[W-2-j])+dp[i-1][j-1]*(ck[max(0,j-2)]-1+ck[W-j-2])\n\nprint(dp[H][K-1]%mod)', 'H, W, K = map(int,input().split())\ndp = [[0]*W for _ in range(H+1)]\ndp[0][0] = 1\n\nck = [0]*9\nck[0] = 1\nfor i in range(1,9):\n for j in range(2**(i-1)):\n for k in range(i-1):\n if (j>>k)&(j>>(k+1))==True:\n break\n else:\n ck[i] += 1\n\nmod = 10**9+7\nfor i in range(1,H+1):\n for j in range(W):\n if (j == 0)&(j == W-1):\n dp[i][j] = dp[i-1][j]*(ck[j]*ck[W-1-j])\n elif j == 0:\n dp[i][j] = dp[i-1][j+1]*(ck[j]*ck[W-j-2])+dp[i-1][j]*(ck[j]*ck[W-1-j])\n elif j == W-1:\n dp[i][j] = dp[i-1][j]*(ck[j]*ck[W-1-j])+dp[i-1][j-1]*(ck[j-1]*ck[W-j-1])\n else:\n dp[i][j] = dp[i-1][j+1]*(ck[j]*ck[W-j-2])+dp[i-1][j]*(ck[j]*ck[W-1-j])+dp[i-1][j-1]*(ck[j-1]*ck[W-j-1])\n\nprint(dp[H][K-1]%mod)']
['Runtime Error', 'Accepted']
['s144046863', 's715871772']
[3064.0, 3064.0]
[20.0, 19.0]
[625, 719]
p03222
u118642796
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['H,W,K = map(int,input().split())\n\ndp = [[0]*(W+2) for _ in range(H+1)]\ndp[0][1] = 1\n\n \n\nfor i in range(1,H+1):\n for x in range(2**(W-1)): \n Alloc = [0]*9\n tmp = x\n for y in range(1,8): \n Alloc[y] = tmp%2\n tmp //= 2 \n for y in range(0,9):\n if Alloc[y] == 1 and Alloc[y+1] == 1:\n break\n else: \n for j in range(1,9): \n if Alloc[j-1] == 1: \n dp[i][j] += dp[i-1][j-1]\n elif Alloc[j] == 1:\n dp[i][j] += dp[i-1][j+1]\n else:\n dp[i][j] += dp[i-1][j]\n dp[i][j] %= 1000000007\n\nprint(dp[H][K])\n', 'H,W,K = map(int,input().split())\n\ndp = [[0]*10 for _ in range(H+1)] \ndp[0][1] = 1\n\n \n\nfor i in range(1,H+1):\n for x in range(2**(W-1)): \n Alloc = [0]*9\n tmp = x\n for y in range(1,8): \n Alloc[y] = tmp%2\n tmp //= 2 \n for y in range(0,9):\n if Alloc[y] == 1 and Alloc[y+1] == 1:\n break\n else: \n for j in range(1,9): \n if Alloc[j-1] == 1: \n dp[i][j] += dp[i-1][j-1]\n elif Alloc[j] == 1:\n dp[i][j] += dp[i-1][j+1]\n else:\n dp[i][j] += dp[i-1][j]\n dp[i][j] %= 1000000007\n\nprint(dp[H][K])\n']
['Runtime Error', 'Accepted']
['s869390791', 's575464539']
[3064.0, 3064.0]
[81.0, 73.0]
[713, 713]
p03222
u160244242
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['input_lst = list(map(int, input().split()))\nh, w, k = input_lst[0], input_lst[1], input_lst[2]\n\ndef row_comb(w):\n if w <= 0:\n return 0\n if w == 1:\n return 1\n if w == 2:\n return 2\n else:\n return row_comb(w-2)+row_comb(w-1)\n\n@lru_cache(maxsize=1000)\ndef trio(h,w):\n if h == 0:\n return [1] + [0 for i in range(w)]\n else:\n lst = []\n for i in range(1, w+1):\n if i == 1:\n lst.append(trio(h-1,w)[0] * row_comb(w-1) + trio(h-1,w)[1] * row_comb(w-2))\n elif i == w:\n lst.append(trio(h-1,w)[w-1] * row_comb(w-1) + trio(h-1,w)[w-2] * row_comb(w-2))\n elif i == 2:\n lst.append(trio(h-1,w)[0] * row_comb(w-2) + trio(h-1,w)[2] * row_comb(w-3) + trio(h-1,w)[1] * row_comb(w-2))\n elif i == w-1:\n lst.append(trio(h-1,w)[w-1] * row_comb(w-2) + trio(h-1,w)[w-3] * row_comb(w-3) + trio(h-1,w)[w-2] * row_comb(w-2))\n elif i > 2 and i < w-1:\n a = row_comb(i-2) * row_comb(w-i)\n b = row_comb(i-1) * row_comb(w-i-1)\n c = row_comb(i-1) * row_comb(w-i)\n lst.append(trio(h-1,w)[i-2] * a + trio(h-1,w)[i] * b + trio(h-1,w)[i-1] * c)\n return lst\n \nprint(trio(h, w)[k-1] % 1000000007)', 'from functools import lru_cache\n\ninput_lst = list(map(int, input().split()))\nh, w, k = input_lst[0], input_lst[1], input_lst[2]\n\ndef row_comb(w):\n if w < 0:\n return 0\n elif w <= 1:\n return 1\n elif w == 2:\n return 2\n else:\n return row_comb(w-2)+row_comb(w-1)\n\n@lru_cache(maxsize=1000)\ndef trio(h,w):\n if h == 0:\n return [1] + [0 for i in range(10)]\n else:\n lst = []\n for i in range(1, w+1):\n if i == 1:\n lst.append(trio(h-1,w)[0] * row_comb(w-1) + trio(h-1,w)[1] * row_comb(w-2))\n elif i == w:\n lst.append(trio(h-1,w)[w-1] * row_comb(w-1) + trio(h-1,w)[w-2] * row_comb(w-2))\n elif i == 2:\n lst.append(trio(h-1,w)[0] * row_comb(w-2) + trio(h-1,w)[2] * row_comb(w-3) + trio(h-1,w)[1] * row_comb(w-2))\n elif i == w-1:\n lst.append(trio(h-1,w)[w-1] * row_comb(w-2) + trio(h-1,w)[w-3] * row_comb(w-3) + trio(h-1,w)[w-2] * row_comb(w-2))\n elif i > 2 and i < w-1:\n a = row_comb(i-2) * row_comb(w-i)\n b = row_comb(i-1) * row_comb(w-i-1)\n c = row_comb(i-1) * row_comb(w-i)\n lst.append(trio(h-1,w)[i-2] * a + trio(h-1,w)[i] * b + trio(h-1,w)[i-1] * c)\n lst = lst + [0 for i in range(10)]\n return lst\n \nprint(trio(h, w)[k-1] % 1000000007)']
['Runtime Error', 'Accepted']
['s356204003', 's764040602']
[3188.0, 3812.0]
[18.0, 35.0]
[1304, 1384]
p03222
u189575640
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left. For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
['from sys import exit\nH,W,K = [int(n) for n in input().split()]\nmemo = [[0 for _ in range(H+1)] for __ in range(W)]\nmemo[0][0] = 1\nfor h in range(1,H+1):\n for pt in range((1 << W-1)):\n pts = bin(pt)[2:]\n pts = pts[::-1]\n if "11" in pts: continue\n # print(pts)\n \n for i in range(W):\n if i < len(pts) and pts[i] == "1":\n # print(i)\n memo[i][h] += memo[i+1][h-1]\n memo[i+1][h] += memo[i][h-1]\n i+=1\n else:\n memo[i][h] += memo[i][h-1]\n for wt in range(0,W):\n # print(memo[wt])\nprint(memo[K-1][H])\n # for wt in range(0,W):\n # print(memo[wt])\n \n \n # print(i)\n # print("BIT:", end="")\n # print(bin(1 << i))\nexit()\n', '\n\nH,W,K = [int(n) for n in input().split()]\nmemo = [[0 for _ in range(W)] for __ in range(H+1)]\nmemo[0][0] = 1\nMOD = 10**9 + 7\nfor h in range(1,H+1):\n for pt in range((1 << W-1)):\n # pts = bin(pt)[2:]\n \n if "11" in bin(pt): continue\n \n goto = [i for i in range(W)]\n for i in range(W):\n if (1 << i) & pt:\n goto[i], goto[i + 1] = goto[i + 1], goto[i]\n for i in range(W):\n memo[h][goto[i]] += memo[h-1][i]\n memo[h][goto[i]] %= MOD\n \nfor ht in range(H+1):\n print(memo[ht])\n\nprint(memo[H][K-1])\n', '\n\nH,W,K = [int(n) for n in input().split()]\nmemo = [[0 for _ in range(W)] for __ in range(H+1)]\nmemo[0][0] = 1\nMOD = 10**9 + 7\nfor h in range(1,H+1):\n for pt in range((1 << W-1)):\n # pts = bin(pt)[2:]\n \n if "11" in bin(pt): continue\n \n goto = [i for i in range(W)]\n for i in range(W):\n if (1 << i) & pt:\n goto[i], goto[i + 1] = goto[i + 1], goto[i]\n for i in range(W):\n memo[h][goto[i]] += memo[h-1][i]\n memo[h][goto[i]] %= MOD\n\n\nprint(memo[H][K-1])\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s338774761', 's662959108', 's888981493']
[3064.0, 3064.0, 3064.0]
[17.0, 46.0, 46.0]
[1072, 737, 656]