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
u319818856
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 identify(N: int, M: int, PY: list) -> list:\n _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]\n _PY.sort(key=lambda x: x[2])\n _PY.sort(key=lambda x: x[1])\n\n now_p = 0\n now_o = 1\n ids = []\n for i, p, _ in _PY:\n if p != now_p:\n now_p = p\n now_o = 1\n ids.append((i, \'{p:08}{o:08}\'.format(p=p, o=now_o)))\n now_o += 1\n\n return [i for _, i in sorted(ids, key=lambda x: x[0])]\n\n\nif __name__ == "__main__":\n N, M = map(int, input().split())\n PY = [tuple(int(s) for s in input().split()) for _ in range(M)]\n for ans in identify(N, M, PY):\n print(ans)\n', 'def identify(N: int, M: int, PY: list) -> list:\n _PY = [(i, p, y) for i, (p, y) in enumerate(PY)]\n _PY.sort(key=lambda x: x[2])\n _PY.sort(key=lambda x: x[1])\n\n now_p = 0\n now_o = 1\n ids = []\n for i, p, _ in _PY:\n if p != now_p:\n now_p = p\n now_o = 1\n ids.append((i, \'{p:06}{o:06}\'.format(p=p, o=now_o)))\n now_o += 1\n\n return [i for _, i in sorted(ids, key=lambda x: x[0])]\n\n\nif __name__ == "__main__":\n N, M = map(int, input().split())\n PY = [tuple(int(s) for s in input().split()) for _ in range(M)]\n for ans in identify(N, M, PY):\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s965874685', 's147677820']
[44748.0, 43980.0]
[804.0, 753.0]
[628, 628]
p03221
u320567105
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.
['2 3\n2 55\n2 77\n2 99', 'ri = lambda: int(input())\nrl = lambda: list(map(int,input().split()))\nrr = lambda N: [ri() for _ in range(N)]\nYN = lambda b: print(\'YES\') if b else print(\'NO\')\nINF = 10**18\n\nN,M=rl()\nP=[0]*M\nY=[0]*M\ndic = [[] for _ in range(N+1)]\nfor i in range(M):\n P[i],Y[i] = rl()\n dic[P[i]] += [Y[i]]\n\nfor i in range(N+1):\n dic[i].sort()\n\nimport bisect\nfor i in range(M):\n print("{:0>6}{:0>6}".format(P[i], bisect.bisect_left(dic[P[i]],Y[i])+1))\n']
['Runtime Error', 'Accepted']
['s793890105', 's020316272']
[2940.0, 30256.0]
[17.0, 718.0]
[18, 445]
p03221
u322297639
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)]\npy.sort(key=lambda x: x[1])\nnow = py[0][0]\ncount = 0\nfor i in range(m):\n if now == py[i][0]:\n count += 1\n else:\n now = py[i][0]\n count = 1\n print("{:06}".format(py[i][0]) + "{:06}".format(count))', 'n, m = map(int, input().split())\npy = [list(map(int, input().split())) for i in range(m)]\npy.sort(key=lambda x: x[1])\nnow = py[0][0]\ncount = 0\nfor i in range(m):\n if now == py[i][0]:\n count += 1\n else:\n now = py[i][0]\n count = 1\n print("{:04}".format(py[i][0]) + "{:04}".format(count))', 'import numpy as np\nn, m = map(int, input().split())\npy = [list(map(int, input().split())) for i in range(m)]\npy2 = [py[i].append(i) for i in range(m)]\npy.sort(key=lambda x: x[1])\nnow = py[0][0]\ncount = 0\nanslist = np.empty((m, 2))\nprint(py)\nfor i in range(m):\n if now == py[i][0]:\n count += 1\n else:\n now = py[i][0]\n count = 1\n anslist[py[i][2], 0] = py[i][0]\n anslist[py[i][2], 1] = count\n\nfor x, y in anslist:\n print("{:06}".format(int(x)) + "{:06}".format(int(y)))', 'n, m = map(int, input().split())\np_y_num_list = sorted([list(map(int, input().split())) + [i] for i in range(m)])\nnow = p_y_num_list[0][0]\nnum = 1\nfor pyn in p_y_num_list:\n if pyn[0] != now:\n num = 1\n now = pyn[0]\n pyn.append(num)\n else:\n pyn.append(num)\n num += 1\np_y_num_list.sort(key=lambda x: x[2])\nfor p, y, i, n in p_y_num_list:\n print("{:06}{:06}".format(p, n))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s025768124', 's297632702', 's871401921', 's960895949']
[29144.0, 29272.0, 49088.0, 31372.0]
[638.0, 641.0, 1071.0, 744.0]
[315, 315, 503, 408]
p03221
u323125813
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_d = {}\nans_l = ["" for _ in range(M)]\nfor i in range(M):\n P,Y = map(int,input().split())\n city_d.setdefault(P,[])\n city_d[P].append([Y,i])\n\nfor p,y_orgnum in city_d.items():\n for j,sorted_y_orgnum in enumerate(sorted(y_orgnum,key=lambda x:x[0])):\n ans_l[sorted_y_orgnum[1]] = str(p).zfill(8) + str(j+1).zfill(8)\n\nfor ans in ans_l:\n print(ans)\n\n\n', 'N,M = map(int,input().split())\ncity_d = {}\nans_l = ["" for _ in range(M)]\nfor i in range(M):\n P,Y = map(int,input().split())\n city_d.setdefault(P,[])\n city_d[P].append([Y,i])\n\nfor p,y_orgnum in city_d.items():\n for j,sorted_y_orgnum in enumerate(sorted(y_orgnum,key=lambda x:x[0])):\n ans_l[sorted_y_orgnum[1]] = str(p).zfill(6) + str(j+1).zfill(6)\n\nfor ans in ans_l:\n print(ans)\n\n\n']
['Wrong Answer', 'Accepted']
['s056225901', 's474013283']
[48780.0, 47616.0]
[812.0, 829.0]
[403, 403]
p03221
u324314500
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\n\ns2nn = lambda s: [int(c) for c in s.split(' ')]\n\nss2nn = lambda ss: [int(s) for s in list(ss)]\nss2nnn = lambda ss: [s2nn(s) for s in list(ss)]\n\ni2s = lambda: sys.stdin.readline().rstrip()\ni2n = lambda: int(i2s())\ni2nn = lambda: s2nn(i2s())\n\nii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]\n\ndef main(N, M, PYm):\n \n \n dic = {}\n \n \n \n #dic2 = {}\n dic2tmp = {}\n for p in range(N+1):\n dic[p] = {}\n #dic2[p] = []\n dic2tmp[p] = []\n for p, y in PYm:\n dic2tmp[p].append(y)\n for p in range(N+1):\n dic2tmp[p].sort()\n nby = [(i+1, y) for i, y in enumerate(dic2tmp[p])]\n #dic2[p] = nby\n for nb, y in nby:\n dic[p][y] = nb\n \n for p, y in PYm:\n nb = dic[p][y]\n print('%06d%06d' % (p, nb))\nN, M = i2nn()\nPYs = ss2nnn(ii2ss())\nmain(N, M, PYs)\n", "import sys\n\ndef i2nn():\n return sp2nn(sys.stdin.readline())\n\ndef ii2ss(n):\n return [sys.stdin.readline() for _ in range(n)]\n\ndef sp2nn(sp, sep=' '):\n return [int(s) for s in sp.split(sep)]\n\ndef ss2nn(ss):\n return [int(s) for s in list(ss)]\n\ndef main(N, ss):\n nn = [[] for _ in range(N+1)]\n for s in ss:\n p, y = sp2nn(s)\n nn[p].append(y)\n for n2 in nn:\n n2.sort()\n for i, n2 in enumerate(nn):\n for n in n2:\n print('%06d%06d' % (i, n))\n\nN, M = i2nn()\nmain(N, ii2ss(M))\n", "import sys\n\ndef i2nn():\n return sp2nn(sys.stdin.readline())\n\ndef ii2ss(n):\n return [sys.stdin.readline() for _ in range(n)]\n\ndef sp2nn(sp, sep=' '):\n return [int(s) for s in sp.split(sep)]\n\ndef ss2nn(ss):\n return [int(s) for s in list(ss)]\n\ndef main(N, ss):\n nn = [[] for _ in range(N+1)]\n for s in ss:\n p, y = sp2nn(s)\n nn[p].append(y)\n for n2 in nn:\n n2.sort()\n for i, n2 in enumerate(nn):\n for j, n in enumerate(n2):\n print('%06d%06d' % (i, j+1))\n\nN, M = i2nn()\nmain(N, ii2ss(M))\n", "import sys\n \ns2nn = lambda s: [int(c) for c in s.split(' ')]\n \nss2nn = lambda ss: [int(s) for s in list(ss)]\nss2nnn = lambda ss: [s2nn(s) for s in list(ss)]\n \ni2s = lambda: sys.stdin.readline().rstrip()\ni2n = lambda: int(i2s())\ni2nn = lambda: s2nn(i2s())\n \nii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]\n \ndef main(N, M, PYm):\n \n \n dic = {}\n \n \n \n #dic2 = {}\n dic2tmp = {}\n for p in range(N+1):\n dic[p] = {}\n #dic2[p] = []\n dic2tmp[p] = []\n for p, y in PYm:\n dic2tmp[p].append(y)\n for p in range(N+1):\n dic2tmp[p].sort()\n nby = [(i+1, y) for i, y in enumerate(dic2tmp[p])]\n #dic2[p] = nby\n for nb, y in nby:\n dic[p][y] = nb\n \n for p, y in PYm:\n nb = dic[p][y]\n print('%06d%06d' % (p, nb))\n\nN, M = i2nn()\nPYs = ss2nnn(ii2ss(M))\nmain(N, M, PYs)\n"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s662867808', 's743801990', 's814004275', 's629482869']
[3064.0, 27436.0, 27168.0, 97520.0]
[18.0, 323.0, 353.0, 585.0]
[1142, 530, 546, 1149]
p03221
u329036729
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\ninfo_list = []\n\nfor i in range(m):\n pi, yi = map(int, input().split())\n info_list.append([i, pi, yi])\nprint(info_list)\n\nfrom operator import itemgetter\ninfo_list.sort(key = itemgetter(1))\ninfo_list.sort(key = itemgetter(2))\nprint(info_list)\n\np = info_list[0][1]\nj = 1\nfor ele in info_list:\n if ele[1] == p:\n ele.append(str(ele[1]).zfill(6) + str(j).zfill(6))\n j+=1\n else:\n p+=1\n j=1\n ele.append(str(ele[1]).zfill(6) + str(j).zfill(6))\n\ninfo_list.sort(key = itemgetter(0))\n\nfor ele in info_list:\n print(ele[3])', 'n, m = map(int, input().split())\n\ninfo_list = []\n\nfor i in range(m):\n pi, yi = map(int, input().split())\n info_list.append([i+1, pi, yi])\nprint(info_list)\n\nfrom operator import itemgetter\ninfo_list.sort(key = itemgetter(2))\nprint(info_list)\n\n\nxth = [1 for i in range(1, n+1)]\nprint(xth)\n\nfor info in info_list:\n info.append(str(info[1]).zfill((6)) + str(xth[info[1]-1]).zfill(6))\n xth[info[1]-1]+=1\n\n\ninfo_list.sort(key = itemgetter(0))\n\nfor ele in info_list:\n print(ele[3])', 'n, m = map(int, input().split())\n\ninfo_list = []\n\nfor i in range(m):\n pi, yi = map(int, input().split())\n info_list.append([i+1, pi, yi])\n# print(info_list)\n\nfrom operator import itemgetter\ninfo_list.sort(key = itemgetter(2))\n# print(info_list)\n\n\nxth = [1 for i in range(1, n+1)]\n# print(xth)\n\nfor info in info_list:\n info.append(str(info[1]).zfill((6)) + str(xth[info[1]-1]).zfill(6))\n xth[info[1]-1]+=1\n\n\ninfo_list.sort(key = itemgetter(0))\n\nfor ele in info_list:\n print(ele[3])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s189264382', 's621615703', 's519323985']
[41004.0, 42032.0, 35028.0]
[983.0, 903.0, 740.0]
[593, 489, 495]
p03221
u333190709
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\nfrom operator import itemgetter\n\nN, M = input().split()\nN, M = int(N), int(M)\nC = [input().split() for i in range(M)]\n\nfor i, c in enumerate(C):\n C[i] = [int(c[0]), int(c[1])]\n C[i].append(i)\n\nC_sorted = sorted(C, key = lambda x: (x[0], x[1]))\n\ncounter = 1\ncurrent = 1\n\nfor c in C_sorted:\n if current < c[0]:\n counter = 1\n pref = str(c[0])\n num = str(counter)\n number = ''\n for i in range(6 - len(pref)):\n number += '0'\n number += pref\n for i in range(6 - len(num)):\n number += '0'\n number += num\n\n c.append(number)\n counter += 1\n current = c[0]\n\nprint(C_sorted)\n\nC_reversed = sorted(C_sorted, key = lambda x: x[2])\n\nfor c in C_reversed:\n print(c[3])", "import numpy as np\nfrom operator import itemgetter\n\nN, M = input().split()\nN, M = int(N), int(M)\nC = [input().split() for i in range(M)]\n\nfor i, c in enumerate(C):\n C[i] = [int(c[0]), int(c[1])]\n C[i].append(i)\n\nC_sorted = sorted(C, key = lambda x: (x[0], x[1]))\n\ncounter = 1\ncurrent = 1\n\nfor c in C_sorted:\n if current < c[0]:\n counter = 1\n pref = str(c[0])\n num = str(counter)\n number = ''\n for i in range(6 - len(pref)):\n number += '0'\n number += pref\n for i in range(6 - len(num)):\n number += '0'\n number += num\n\n c.append(number)\n counter += 1\n current = c[0]\n\nC_reversed = sorted(C_sorted, key = lambda x: x[2])\n\nfor c in C_reversed:\n print(c[3])"]
['Wrong Answer', 'Accepted']
['s430774058', 's863811270']
[62264.0, 50228.0]
[1234.0, 1141.0]
[692, 675]
p03221
u334712262
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, \'sec\')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, M, PY):\n PY.sort(key=lambda x: x[1])\n\n id = []\n pc = Counter()\n for p, y in PY:\n pc[p] += 1\n id.append("%06d%06d" % (p, pc[p]))\n\n id.sort()\n for i in id:\n print(i)\n\n\ndef main():\n N, M = read_int_n()\n PY = [read_int_n() for _ in range(M)]\n slv(N, M, PY)\n\n\nif __name__ == \'__main__\':\n main()\n', '# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, \'sec\')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, M, PY):\n PY.sort(key=lambda x: x[1])\n\n id = []\n pc = Counter()\n for p, y in PY:\n pc[p] += 1\n id.append("%06d%06d" % (p, pc[p]))\n\n id.sort(key=lambda x: x[6:])\n for i in id:\n print(i)\n\n\ndef main():\n N, M = read_int_n()\n PY = [read_int_n() for _ in range(M)]\n slv(N, M, PY)\n\n\nif __name__ == \'__main__\':\n main()\n', '# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, \'sec\')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, M, PY):\n PY = [(p, y, i) for i, (p, y) in enumerate(PY)]\n PY.sort(key=lambda x: x[1])\n\n id = []\n pc = Counter()\n for p, y, i in PY:\n pc[p] += 1\n id.append(("%06d%06d" % (p, pc[p]), i))\n\n id.sort(key=lambda x: x[1])\n for s, _ in id:\n print(s)\n\n\ndef main():\n N, M = read_int_n()\n PY = [read_int_n() for _ in range(M)]\n slv(N, M, PY)\n\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s072877200', 's643488944', 's893337011']
[45872.0, 49324.0, 63308.0]
[895.0, 756.0, 825.0]
[1349, 1368, 1430]
p03221
u335278042
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=[]\nfor i in range(M):\n lis.append(list(map(int,input().split())))\nl_2=sorted(lis, key=lambda x: x[1])\ndic={}\nfor i,j in l_2:\n dic[i]=dic.get(i,0)+1\n res='{:0=6}{:0=6}'.format(i,dic[i])\n lis[lis.index([i,j])]=res\nprint(lis)", "import sys\ninput=sys.stdin.readline\n\nN,M=map(int, input().split())\nlis={}\nly=[]\nfor i in range(M):\n t1,t2 =list(map(int,input().split()))\n lis[t2]=t1\n ly.append(t2)\nd={}\nfor i in sorted(lis):\n d[lis[i]]=d.get(lis[i],0)+1\n ly[ly.index(i)]=[lis[i],d[lis[i]]\n\n\n\nfor i in ly:print('{:0=6}{:0=6}'.format(i[0],i[1]))", "import sys\ninput=sys.stdin.readline\n\nN,M=[int(n) for n in input().split()]\nlis=[[i]+[int(n) for n in input().split()] for i in range(M)]\nprint(lis)\nl_2=sorted(lis, key=lambda x: x[2])\ndic={}\nfor k,i,j in l_2:\n dic[i]=dic.get(i,0)+1\n lis[k]='{:0=6}{:0=6}'.format(i,dic[i])\nfor i in lis:print(i)", "import sys\ninput=sys.stdin.readline\n\nN,M=[int(n) for n in input().split()]\nlis=[[i]+[int(n) for n in input().split()] for i in range(M)]\n#print(lis)\nl_2=sorted(lis, key=lambda x: x[2])\ndic={}\nfor k,i,j in l_2:\n dic[i]=dic.get(i,0)+1\n lis[k]='{:0=6}{:0=6}'.format(i,dic[i])\nfor i in lis:print(i)"]
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s098778777', 's208514256', 's751699341', 's179363128']
[30224.0, 3064.0, 43928.0, 38324.0]
[2109.0, 17.0, 520.0, 468.0]
[268, 325, 299, 300]
p03221
u335295553
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(N)]\n\nPY_sort = sorted(PY)\n\ntmp = dict()\n\nbefore = 0\nfor py in PY_sort:\n if before != py[0]:\n count = 0\n count += 1\n tmp[py] = count\n\nfor py in PY:\n print("{:06}{:06}".format(tmp[py][0],tmp[py][1]))', 'N, M = map(int, input().split())\nPY = [tuple(map(int,input().split())) for i in range(M)]\n\nPY_sort = sorted(PY)\n\ntmp = dict()\n\nbefore = 0\nfor py in PY_sort:\n if before != py[0]:\n before = py[0]\n count = 0\n count += 1\n tmp[py] = count\n\nfor py in PY:\n print("{:06}{:06}".format(py[0],tmp[py]))']
['Runtime Error', 'Accepted']
['s902856329', 's659099273']
[28656.0, 29316.0]
[491.0, 600.0]
[301, 317]
p03221
u343671593
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['N,M = map(int,input().split())\np,y = 0,0\nmy_dict = dict()\ndef genFrstSix(P):\n\tstr_ = str(P)\n\twhile(len(str(str_))<6):\n\t\tstr_ = "0"+ str_\n\t\t# print(str_)\n\treturn str_\nP,Y,tup=[],[],[]\nfor i in range(M):\n\tp,y = map(int,input().split())\n\ttup.append((p,y))\n\tif p in my_dict.keys():\n\t\tmy_dict[p].append(y)\n\telse:\n\t\tmy_dict[p] = [y]\n\t\nL = []\nfor key,values in sorted(my_dict.items(), key =lambda x: x[0]):\n\t# print(key,values)\n\tfor each in values:\n\t\tL.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])\n# print(L)\n# print(tup)\nfor i in range(len(tup)):\n\tfor j in range(len(L)):\n\t\t# print(tup[i],L[j][0])\n\t\tif tup[i] == L[j][0]:\n\t\t\tprint(L[j][1])\n\n', 'N,M = map(int,input().split())\np,y = 0,0\nmy_dict = dict()\ndef genFrstSix(P):\n\tstr_ = str(P)\n\twhile(len(str(str_))<6):\n\t\tstr_ = "0"+ str_\n\t\t# print(str_)\n\treturn str_\nP,Y,tup=[],[],[]\nfor i in range(M):\n\tp,y = map(int,input().split())\n\tP.append(p)\n\tY.append(y)\n\ttup.append((p,y))\n\nfor i in range(len(P)):\n\tif P[i] in my_dict.keys():\n\t\tmy_dict[P[i]].append(Y[i])\n\telse:\n\t\tmy_dict[P[i]] = [Y[i]]\n# print(my_dict)\n\n# print(genFrstSix(12))\n# print(my_dict)\nL = []\nfor key,values in sorted(my_dict.items(), key =lambda x: x[0]):\n\t# print(key,values)\n\tfor each in values:\n\t\tL.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])\n# print(L)\n# print(tup)\nfor i in range(len(tup)):\n\tfor j in range(len(L)):\n\t\t# print(tup[i],L[j][0])\n\t\tif tup[i] == L[j][0]:\n\t\t\tprint(L[j][1])\n\n', 'N,M = map(int,input().split())\np,y = 0,0\nmy_dict = dict()\ndef genFrstSix(P):\n\tstr_ = str(P)\n\twhile(len(str(str_))<6):\n\t\tstr_ = "0"+ str_\n\t\t# print(str_)\n\treturn str_\nP,Y,tup=[],[],[]\nfor i in range(M):\n\tp,y = map(int,input().split())\n\ttup.append((p,y))\n\tif p in my_dict.keys():\n\t\tmy_dict[p].append(y)\n\telse:\n\t\tmy_dict[p] = [y]\n\nprint(tup)\t\nL = []\n\nfor key,values in my_dict.items():\n\tfor each in values:\n\t\tL.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])\n\t\t\n# for key,values in sorted(my_dict.items(), key =lambda x: x[0]):\n# \t# print(key,values)\n\t# for each in values:\n\t# \tL.append([(key,each),genFrstSix(key)+genFrstSix(values.index(each)+1)])\n\nfor i in range(len(tup)):\n\tfor j in range(len(L)):\n\t\t# print(tup[i],L[j][0])\n\t\tif tup[i] == L[j][0]:\n\t\t\tprint(L[j][1])\n\n', 'N,M = map(int,input().split())\np,y = 0,0\nmy_dict = dict()\ndef genFrstSix(P):\n\tstr_ = str(P)\n\twhile(len(str(str_))<6):\n\t\tstr_ = "0"+ str_\n\t\t# print(str_)\n\treturn str_\ntup,P,Y= [],[],[]\nfor i in range(M):\n\tp,y = map(int,input().split())\n\ttup.append((p,y))\n\tif p in my_dict.keys():\n\t\tmy_dict[p].append(y)\n\telse:\n\t\tmy_dict[p] = [y]\n\n\nfor key in my_dict.keys():\n\tsorted_y = sorted(my_dict[key])\n\tys = {y:i+1 for i,y in enumerate(sorted_y)}\n\t# if key in L.keys():\n\tmy_dict[key] = ys\t\n\t# else:\n\t\t# L[key]\n# print(my_dict)\nfor each in tup:\n\t# print(each)\n\t# for p,y in each:\n\tp = each[0]\n\ty = each[1]\n\tprint(\'{:06}{:06}\'.format(p,my_dict[p][y]))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s209785834', 's346366389', 's690700316', 's891131943']
[62096.0, 64108.0, 56948.0, 54428.0]
[2107.0, 2107.0, 2107.0, 765.0]
[660, 783, 846, 694]
p03221
u346194435
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 numbering(Y, P):\n \n \n idx = int(P) - 1\n Pwas[idx] = Pwas[idx] + 1\n num = P.zfill(6) + str(Pwas[idx]).zfill(6)\n return num\n\nN, M = input().split()\nN = int(N)\nM = int(M)\nPY = []\nPwas = [0 for i in range(N)]\n\nfor i in range(M):\n Px, Yy = input().split()\n \n PY.append((Yy, Px))\n\nPY.sort()\n\nfor x in PY:\n print(numbering(x[0], x[1]))', 'N, M = input().split()\nN = int(N)\nM = int(M)\nPY = []\nfor i in range(M):\n P, Y = input().split()\n PY.append((P, Y, i))\n\nsortedPY = sorted(PY, key=lambda x:int(x[1]))\n\nPwas = [0 for i in range(N)]\nfor i,x in enumerate(sortedPY):\n P = x[0]\n idx = int(P) - 1\n Pwas[idx] = Pwas[idx] + 1\n PY[x[2]] = P.zfill(6) + str(Pwas[idx]).zfill(6)\n\nfor x in PY:\n print(x)']
['Wrong Answer', 'Accepted']
['s251844464', 's826765128']
[24256.0, 35940.0]
[545.0, 539.0]
[468, 375]
p03221
u346395915
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['n,m = map(int,input().split())\n\ncity = [[] for _ in range(n+1)]\narr = []\n\nfor i in range(m):\n s,t = map(int,input().split())\n city[s].append(t)\n arr.append((s,t))\n \nfor i in range(m):\n x = str(arr[i][0])\n y = str(city[int(x)].index(arr[i][1]))\n print(x.rjust(6, "0") + y.rjust(6,"0"))\n\n ', 'import collections\nimport bisect\n\nn,m = map(int,input().split())\n \ncity = [[] for _ in range(n+1)]\narr = []\n \nfor i in range(m):\n s,t = map(int,input().split())\n arr.append((s,t))\n \ncity =collections.defaultdict(list)\n\nfor x,y in sorted(arr):\n city[x] += [y]\nfor x,y in arr:\n z=str(bisect.bisect(city[x],y))\n print(str(x).rjust(6, "0") + z.rjust(6,"0"))\n']
['Wrong Answer', 'Accepted']
['s938573108', 's278160515']
[29608.0, 36336.0]
[2105.0, 696.0]
[311, 369]
p03221
u346629192
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())\npairs = [list(map(int,input().split())) for i in range(M)]\n\np_count = [1] * (N + 1)\nfor r in sorted(pairs, key=lambda x: x[1]):\n r.append("{:06}{:06}".format(r[0], p_count[r[0]]))\n p_count[r[0]] += 1\nprint(pairs)\n\nprint("\\n".join((r[2] for r in pairs)))', 'N, M = map(int, input().split())\npairs = [list(map(int,input().split())) for i in range(M)]\n\np_count = [1] * (N + 1)\nfor r in sorted(pairs, key=lambda x: x[1]):\n r.append("{:06}{:06}".format(r[0], p_count[r[0]]))\n p_count[r[0]] += 1\n\nprint("\\n".join((r[2] for r in pairs)))']
['Wrong Answer', 'Accepted']
['s758841139', 's745933062']
[46052.0, 39028.0]
[624.0, 531.0]
[292, 279]
p03221
u347640436
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['from bisect import bisect_left\nn, m = map(int, input().split())\ndata = [list(map(int, input().split())) for _ in range(n)]\nt = [[] for _ in range(n)]\nfor p, y in data:\n t[p - 1].append(y)\nfor i in range(n):\n t[i].sort()\nfor p, y in data:\n nth = bisect_left(t[p - 1], y) + 1\n print("%06d%06d" % (p, nth))\n', 'n, m = map(int, input().split())\ndata = [list(map(int, input().split())) for _ in range(n)]\nt = [[] for _ in range(n)]\nfor p, y in data:\n t[p - 1].append(y)\nfor i in range(n):\n t[i].sort()\nfor p, y in data:\n nth = t[p - 1].index(y) + 1\n print("%06d%06d" % (p, nth))\n', '\nfrom bisect import bisect_left\n\nN, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\n\nt = [[] for _ in range(N)]\nfor P, Y in PY:\n t[P - 1].append(Y)\n\nfor i in range(N):\n t[i].sort()\n\nfor P, Y in PY:\n print("%06d%06d" % (P, bisect_left(t[P - 1], Y) + 1))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s614502608', 's639226774', 's763452019']
[37300.0, 35936.0, 36748.0]
[638.0, 2106.0, 648.0]
[308, 270, 315]
p03221
u350997995
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 = []\narr = [[]for j in range(10**5)]\nfor i in range(M):\n listA = list(map(int,input().split()))\n P.append(listA[0])\n Y.append(listA[1])\n arr[listA[0]].append(listA[1])\n arr[listA[0]].sort()\nfor i in range(M):\n num = Y[i]\n for k in range(M):\n if arr[P[i]][k] == Y[i]:\n break\n print(str(P[i]).rjust(6,'0')+str(k+1).rjust(6,'0'))\nprint(arr)\n", 'from collections import defaultdict\nfrom bisect import bisect\nN,M,*P = map(int,open(0).read().split())\nd = defaultdict(list)\nZ = set()\nfor n,m in zip(*[iter(P)]*2):\n d[n].append(m)\n Z.add(n)\nfor z in Z:\n d[z].sort()\nfor n,m in zip(*[iter(P)]*2):\n print(str(n).zfill(6)+str(bisect(d[n],m)).zfill(6))']
['Runtime Error', 'Accepted']
['s376994541', 's177857112']
[34000.0, 33896.0]
[2105.0, 375.0]
[394, 310]
p03221
u354916249
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['N,M = map(int, input().split())\nPY = [list(map(int,input().split())) for _ in range(M)]\nPY_originals = tuple(PY)\nN_counter = [0] * N\nM_counter = [0] * M\n\nPY.sort(key=lambda val: val[1])\n\nfor i in range(M):\n N_counter[PY[1]-1] += 1\n M_counter[i] = N_counter[PY[1]-1]\n\nfor i in PY_originals:\n ans = str(i[0]).zfill(6)+str(M_counter[PY.index(i)]).zfill(6)\n print(ans)\n', 'N,M = map(int, input().split())\nPY = []\nfor i in range(M):\n temp1, temp2 = map(int, input().split())\n PY.append([i,temp1,temp2])\n\nPY.sort(key=lambda val: val[2])\nPY.sort(key=lambda val: val[1])\n\nj = 0\ncity = 0\n\nfor i, value in enumerate(PY):\n if value[1] != city:\n j = 0\n j += 1\n value.append(j)\n city = value[1]\n\n\n\nPY.sort(key=lambda val: val[0])\n\nfor i in PY:\n ans = str(i[1]).zfill(6)+str(i[3]).zfill(6)\n print(ans)\n']
['Runtime Error', 'Accepted']
['s106141280', 's124557094']
[31452.0, 31012.0]
[409.0, 854.0]
[377, 461]
p03221
u357751375
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 = [[] for i in range(m)]\nfor i in range(m):\n a,b = map(int,input().split())\n l[i] = [a,b,i]\nl = list(sorted(l,key=lambda x: x[0]))\nans = [[] for i in range(m)]\nx = 0\ny = 1\nfor i in range(m):\n if x != l[i][0]:\n x = l[i][0]\n y = 1\n else:\n y += 1\n a = str(x).zfill(6)\n b = str(y).zfill(6)\n ans[i] = [a+b,l[i][2]]\nans = list(sorted(ans,key=lambda x: x[1]))\nfor i in range(m):\n print(ans[i][0])', 'n,m = map(int,input().split())\nl = [[] for i in range(m)]\nfor i in range(m):\n a,b = map(int,input().split())\n l[i] = [a,b,i]\nl = list(sorted(l,key=lambda x: (x[0], x[1])))\nans = [[] for i in range(m)]\nx = 0\ny = 1\nfor i in range(m):\n if x != l[i][0]:\n x = l[i][0]\n y = 1\n else:\n y += 1\n a = str(x).zfill(6)\n b = str(y).zfill(6)\n ans[i] = [a+b,l[i][2]]\nans = list(sorted(ans,key=lambda x: x[1]))\nfor i in range(m):\n print(ans[i][0])']
['Wrong Answer', 'Accepted']
['s540098589', 's914135009']
[46204.0, 45816.0]
[623.0, 707.0]
[467, 475]
p03221
u360515075
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\nimport bisect\nN, M = map(int, input().split())\nP = [[int(i) for i in input().split()] for _ in range(M)]\nD = defaultdict(list)\n\nfor p, y in sorted(P):\n D[p] += [y]\n \nfor p, y in sorted(P):\n z = D[p].index(y)\n print ("%06d%06d"%(p, z+1))\n', 'from collections import defaultdict\nimport bisect\nN, M = map(int, input().split())\nP = [[int(i) for i in input().split()] for _ in range(M)]\nD = defaultdict(list)\n\nfor p, y in sorted(P):\n D[p] += [y]\n \nfor p, y in P:\n z = bisect.bisect(D[p], y)\n print ("%06d%06d"%(p, z))\n']
['Wrong Answer', 'Accepted']
['s395218043', 's669721366']
[41032.0, 41012.0]
[2106.0, 681.0]
[277, 276]
p03221
u361381049
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 = list(map(int, input().split()))\n a.append(i)\n py.append(a)\n\npy = sorted(py, key=lambda x:x[1])\npy = sorted(py, key=lambda x:x[0])\n#print(py)\n\nans = [[0] * 2 for i in range(m)]\ncnt = 0\nval = py[0][2]\nfor i in range(m):\n if py[i][2] != val:\n cnt = 0\n cnt += 1\n\n ans[py[i][2]][0] = py[i][0]\n ans[py[i][2]][1] = cnt\n#print(ans)\nfor i in range(m):\n print('0' * (6 - len(str(ans[i][0]))) + str(ans[i][0]) + '0' * (6 - len(str(ans[i][1]))) + str(ans[i][1]))\n", "n, m = map(int, input().split())\npy = []\nfor i in range(m):\n a = list(map(int, input().split()))\n a.append(i)\n py.append(a)\n\npy = sorted(py, key=lambda x:x[1])\npy = sorted(py, key=lambda x:x[0])\n#print(py)\n\nans = [[0] * 2 for i in range(m)]\ncnt = 0\nval = py[0][0]\nfor i in range(m):\n #print(val)\n if py[i][0] != val:\n cnt = 0\n val = py[i][0]\n cnt += 1\n\n ans[py[i][2]][0] = py[i][0]\n ans[py[i][2]][1] = cnt\n#print(ans)\nfor i in range(m):\n print('0' * (6 - len(str(ans[i][0]))) + str(ans[i][0]) + '0' * (6 - len(str(ans[i][1]))) + str(ans[i][1]))\n"]
['Wrong Answer', 'Accepted']
['s898900157', 's320530102']
[39188.0, 42212.0]
[925.0, 930.0]
[547, 586]
p03221
u366886346
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())\nnum=[]\nans=[""]*m\ncount=1\nfor i in range(m):\n p,y=input().split()\n num.append([p,y,i])\nprint(num)\nstry= lambda val: val[1]\nnum.sort(key=stry)\nstrp= lambda val: val[0]\nnum.sort(key=strp)\nfor i in range(m):\n p=str(num[i][0])\n if i!=0 and num[i][0]==num[i-1][0]:\n count+=1\n y=str(count)\n else:\n count=1\n y=str(count)\n ans[num[i][2]]="0"*(6-len(p))+p+"0"*(6-len(y))+y\nfor i in range(m):\n print(ans[i])\n', 'n,m=map(int,input().split())\nnum=[]\nans=[""]*m\nnumcount=[1]*n\ncount=1\nfor i in range(m):\n p,y=map(int,input().split())\n num.append([p,y,i])\nstry= lambda val: val[1]\nnum.sort(key=stry)\nprint(num)\nfor i in range(m):\n p=str(num[i][0])\n y=str(numcount[int(num[i][0])-1])\n numcount[int(num[i][0])-1]+=1\n ans[num[i][2]]="0"*(6-len(p))+p+"0"*(6-len(y))+y\nfor i in range(m):\n print(ans[i])\n', 'n,m=map(int,input().split())\nnum=[]\nans=[""]*m\nnumcount=[1]*n\ncount=1\nfor i in range(m):\n p,y=map(int,input().split())\n num.append([p,y,i])\nstry= lambda val: val[1]\nnum.sort(key=stry)\nfor i in range(m):\n p=str(num[i][0])\n y=str(numcount[int(num[i][0])-1])\n numcount[int(num[i][0])-1]+=1\n ans[num[i][2]]="0"*(6-len(p))+p+"0"*(6-len(y))+y\nfor i in range(m):\n print(ans[i])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s731925607', 's933489064', 's879109070']
[41396.0, 35472.0, 32212.0]
[752.0, 745.0, 707.0]
[476, 403, 392]
p03221
u371467115
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 _ in range(n)]\nans=[None]*n\n\nfor i in range(m):\n p,y=map(int,input().split())\n a.append((y,i))\n \nfor i,b in enumerate(a):\n b.sort()\n for j,(y,k) in b:\n ans[k]='%06d%06d' % (i+1,j+1)\n \nprint(*ans,sep='\\n')", "n,m=map(int,input().split())\na=[[] for _ in range(n)]\nans=[None]*m\n\nfor i in range(m):\n p,y=map(int,input().split())\n a[p-1].append((y,i))\n \nfor i,b in enumerate(a):\n b.sort()\n for j,(y,k) in enumerate(b):\n ans[k]='%06d%06d' % (i+1,j+1)\n \nprint(*ans,sep='\\n')"]
['Runtime Error', 'Accepted']
['s161140131', 's462881583']
[24488.0, 37480.0]
[354.0, 592.0]
[254, 270]
p03221
u373274281
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+1)\nY = [0]*(m+1)\nfor i in range(1, m+1):\n P[i], Y[i] = map(int, input().split())\nPP = [[] for i in range(n+1)]\n#print(PP)\nfor i in range(1, m+1):\n p = P[i]\n y = Y[i]\n PP[p].append((i, y))\n\nfor i in range(1, n+1):\n if len(PP[i]) == 0:\n continue\n for j in range(1, len(PP[i])+1):\n print('%06d%06d' % (i, j))\n #if len(PP[i]) > 1:\n # PP[i].sort(key=lambda x: x[1])\n #for i, pp in enumerate(PP[i]):\n ", "n, m = map(int, input().split())\nP = [0]*(m+1)\nY = [0]*(m+1)\nfor i in range(1, m+1):\n P[i], Y[i] = map(int, input().split())\nPP = [[] for i in range(n+1)]\n#print(PP)\nfor i in range(1, m+1):\n p = P[i]\n y = Y[i]\n PP[p].append((i, y))\n\nC = []\nfor i in range(1, n+1):\n if len(PP[i]) == 0:\n continue\n if len(PP[i]) > 1:\n PP[i].sort(key=lambda x: x[1])\n for j, pp in enumerate(PP[i]):\n num = '%06d%06d' % (P[pp[0]], j+1)\n C.append((pp[0], num))\n#print(C)\nC.sort(key=lambda x: x[0])\nfor i, num in C:\n print(num)"]
['Wrong Answer', 'Accepted']
['s148292592', 's169312670']
[33536.0, 47324.0]
[578.0, 726.0]
[516, 556]
p03221
u374103100
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\nN, M = map(int, input().split())\nc_l = [list(map(int, input().split())) for _ in range(M)]\n\ndict = {}\n\nfor c in c_l:\n if c[0] in dict:\n dict[c[0]].append(c[1])\n else:\n dict[c[0]] = [c[1]]\n\n\nfor k, v in dict.items():\n v.sort()\n\nprint(dict)\n\nfor c in c_l:\n idx = dict[c[0]].index(c[1]) + 1\n print("{:06}{:06}".format(c[0], idx))\n\n\n\n\n', '\n\nN, M = map(int, input().split())\nc_l = [[int(i) for i in input().split()] + [j] for j in range(M)]\n\n# print(c_l)\nc_l.sort(key=lambda x: x[1])\n\ncounter = [0] * (N+1)\nfor c in c_l:\n p = c[0]\n counter[p] += 1\n c.append("{:06}{:06}".format(c[0], counter[p]))\n\nc_l.sort(key=lambda x: x[2])\n\nfor c in c_l:\n print(c[3])\n\n']
['Wrong Answer', 'Accepted']
['s125033851', 's043122654']
[46880.0, 35008.0]
[2105.0, 746.0]
[413, 379]
p03221
u374671031
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for i in range(M)]\n\nA = []\nfor i in range(M):\n A.append([0,1000000000000])\n\nfor i in range(M):\n PY[i].extend(A[i])\n\nPY.sort\n\nP = 0\n\n\nfor i in range(M):\n if P != PY[i][0]:\n P = PY[i][0]\n S = 1\n\n else:\n S += 1\n\n PY[i][3] += PY[i][0]*1000000+S\n\nPY.sort(key=lambda x: x[2])\n\nfor i in range(M):\n ans = str(PY[i][3])\n print(ans[1:])\n', 'N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for i in range(M)]\n\nA = []\nfor i in range(M):\n A.append([i,1000000000000])\n\nfor i in range(M):\n PY[i].extend(A[i])\n\nPY.sort()\n\nP = 0\n\n\nfor i in range(M):\n if P != PY[i][0]:\n P = PY[i][0]\n S = 1\n\n else:\n S += 1\n\n PY[i][3] += PY[i][0]*1000000+S\n\nPY.sort(key=lambda x: x[2])\n\nfor i in range(M):\n ans = str(PY[i][3])\n print(ans[1:])']
['Wrong Answer', 'Accepted']
['s896747548', 's285880294']
[40020.0, 43528.0]
[559.0, 816.0]
[415, 426]
p03221
u374802266
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\ndef zaatu(a):\n b=list(set(a))\n for i in range(len(a)):\n a[i]=bisect.bisect_left(b,a[i])\n return a\nn,m=map(int,input().split())\na=[[] for _ in range(n)]\nb=[]\nfor i in range(m):\n p,y=map(int,input().split())\n a[p-1].append([p,y,i])\nfor i in range(n):\n a[i].sort(key=lambda x:x[1])\nfor i in range(n):\n for j in range(len(a[i])):\n b.append([a[i][j],j+1])\nb.sort(key=lambda x:x[0][2])\nprint(b)\nfor i in b:\n print('0'*(6-len(str(i[0][0])))+str(i[0][0])+'0'*(6-len(str(i[1])))+str(i[1]))", "import bisect\ndef zaatu(a):\n b=list(set(a))\n for i in range(len(a)):\n a[i]=bisect.bisect_left(b,a[i])\n return a\nn,m=map(int,input().split())\na=[[] for _ in range(n)]\nb=[]\nfor i in range(m):\n p,y=map(int,input().split())\n a[p-1].append([p,y,i])\nfor i in range(n):\n a[i].sort(key=lambda x:x[1])\nfor i in range(n):\n for j in range(len(a[i])):\n b.append([a[i][j],j+1])\nb.sort(key=lambda x:x[0][2])\nfor i in b:\n print('0'*(6-len(str(i[0][0])))+str(i[0][0])+'0'*(6-len(str(i[1])))+str(i[1]))"]
['Wrong Answer', 'Accepted']
['s782336842', 's991562849']
[56616.0, 49352.0]
[898.0, 764.0]
[532, 523]
p03221
u375616706
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["\nN, M = map(int,input().split())\nP=[]\nY=[]\ncities=[]\nfor i in range(M):\n try:\n s = input()\n p,y = s.split()\n city=(p,y)\n cities.append(city) \n P.append(p)\n Y.append(y)\n\n except:\n break\nsort_city=sorted(cities,key=lambda x:(x[0],x[1]))\nprefs = sorted(set(P))\n\naddress=[]\nres=[]\nfor i in range(len(sort_city)): \n address=str(sort_city[i][0]).rjust(6,'0')+str(i+1).rjust(6,'0')\n res.append((sort_city[i],address))\n\nprint(res[1][0])\nfor i in range(len(cities)):\n for j in range(len(res)):\n if cities[i] == res[j][0]:\n print(res[j][1])\n", "#M num of prefecture\n#N num of city\nN, M = map(int,input().split())\n#P pref\n#Y year\nP=[]\nY=[]\ncities=[]\nfor i in range(M):\n try:\n s = input()\n p,y = s.split()\n city=(p,y)\n cities.append(city) \n P.append(p)\n Y.append(y)\n except:\n break\n\nsort_city=sorted(cities,key=lambda x:(x[0],x[1]))\nprefs = sorted(set(P))\n\naddress=[]\nres=[]\nfor i in range(len(sort_city)):\n pref_n =prefs.index(sort_city[i][0])\n address=str(pref_n+1).rjust(6,'0')+str(i+1).rjust(6,'0')\n res.append((sort_city[i],address))\n\nprint(res[1][0])\nfor i in range(len(cities)):\n for j in range(len(res)):\n if cities[i] == res[j][0]:\n print(res[j][1])\n\n", "#M num of prefecture\n#N num of city\nN, M = map(int,input().split())\n#P pref\n#Y year\nP=[]\nY=[]\ncities=[]\nfor i in range(M):\n try:\n s = input()\n p,y = s.split()\n city=(p,y)\n cities.append(city) \n P.append(p)\n Y.append(y)\n except:\n break\n\nsort_city=sorted(cities,key=lambda x:(x[0],x[1]))\nprefs = sorted(set(P))\n\naddress=[]\nres=[]\nfor i in range(len(sort_city)): \n address=str(sort_city[i][0]).rjust(6,'0')+str(i+1).rjust(6,'0')\n res.append((sort_city[i],address))\n\nprint(res[1][0])\nfor i in range(len(cities)):\n for j in range(len(res)):\n if cities[i] == res[j][0]:\n print(res[j][1])\n break\n\n", "N,M=map(int,input().split())\nP=[]\nY=[]\ncities=[]\nfor i in range(M):\n try:\n s = input()\n p,y = s.split()\n city=(p,y)\n cities.append(city) \n P.append(p)\n Y.append(y)\n \n except:\n break\nsort_city=sorted(cities,key=lambda x:(x[0],x[1]))\nprefs = sorted(set(P))\n \na=0\nb=0\nfor i in sort_city:\n if i[0]==b:\n a+=1\n else:\n a=1\n b=i[0]\n print(str(i[0]).rjust(6,'0')+str(a).rjust(6,'0'))\n\n", "#M num of prefecture\n#N num of city\nN, M = map(int,input().split())\n#P pref\n#Y year\nP=[]\nY=[]\ncities=[]\nfor i in range(M):\n try:\n s = input()\n p,y = s.split()\n city=(p,y)\n cities.append(city) \n P.append(p)\n Y.append(y)\n except:\n break\n\nsort_city=sorted(cities,key=lambda x:(x[0],x[1]))\nprefs = sorted(set(P))\n\naddress=[]\nres=[]\nfor i in range(len(sort_city)): \n address=str(sort_city[i][0]).rjust(6,'0')+str(i+1).rjust(6,'0')\n res.append((sort_city[i],address))\n\nprint(res[1][0])\nfor i in range(len(cities)):\n for j in range(len(res)):\n if cities[i] == res[j][0]:\n print(res[j][1])\n\n", "n,m = map(int,input().split())\nl = [list(map(int,input().split())) for i in range(m)]\ns = []\nfor i in enumerate(l):\n s.append(i)\na = 1\nfor i in range(m):\n if i==0:\n s[0][1][1]=1\n elif s[i][1][0]==s[i-1][1][0]:\n a+=1\n s[i][1][1]=a\n elif s[i][1][0] != s[i-1][1][0]:\n a=1\n s[i][1][1]=a\ns = sorted(s,key=lambda x:x[0])\nfor i in s:\n print('%06d'%i[1][0]+'%06d'%i[1][1])\n", "n,m=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(m)]\ns=[]\nfor i in enumerate(l):\n s.append(i)\ns=sorted(s,key=lambda x:(x[1][0],x[1][1]))\na=0\nfor i in range(m):\n if s[i][1][0]==0:\n a=1 \n elif s[i][1][0]==s[i-1][1][0]:\n a+=1\n elif s[i][1][0]!=s[i-1][1][0]:\n a=1\n s[i][1][1]=a\ns = sorted(s,key=lambda x:x[0])\nfor i in s:\n print('%06d'%i[1][0]+'%06d'%i[1][1])\n"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s027523863', 's115322167', 's427926557', 's461336302', 's783833355', 's793556776', 's580570941']
[39824.0, 37780.0, 38764.0, 37448.0, 40472.0, 39392.0, 46748.0]
[2106.0, 2106.0, 2106.0, 763.0, 2106.0, 579.0, 824.0]
[613, 698, 683, 461, 665, 415, 427]
p03221
u377989038
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 lst = [[] for _ in range(n + 1)]\n py = []\n for i in range(m):\n p, y = map(int, input().split())\n py.append([p, y])\n lst[p].append(y)\n\n for i in lst:\n i.sort\n ans = []\n for i, j in py:\n ans.append(str(i).zfill(6) + str(lst[i].index(j)+1).zfill(6))\n print(*ans, sep=('\\n'))\n\n\nif __name__ == '__main__':\n main()", 'n, m = map(int, input().split())\nlst = [[] for _ in range(n + 1)]\npy = [None] * m\nfor i in range(m):\n p, y = map(int, input().split())\n py[i] = [p, y]\n lst[p].append(y)\n\nfor i in range(n + 1):\n lst[i] = {v: i for i, v in enumerate(sorted(lst[i]))}\n\nfor i, j in py:\n print(str(i).zfill(6) + str(lst[i][j]+1).zfill(6))']
['Wrong Answer', 'Accepted']
['s013870070', 's976750652']
[41380.0, 63808.0]
[2105.0, 735.0]
[457, 331]
p03221
u382176416
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['from operator import itemgetter\nn,m=map(int,input().split())\nl=[]\nid_list=[]\nfor i in range(m):\n l.append(list(map(int, input().split())))\nl=sorted(l, key=itemgetter(1))\nidx=0\nfor j in range(m):\n if j == 0:\n idx=1\n else:\n if l[j][0] == l[j-1][0]:\n idx+=1\n else:\n idx =1\n id_list.append(str(l[j][0]).zfill(6)+str(idx).zfill(6))\nprint(sorted(id_list))', 'from operator import itemgetter\nn,m=map(int,input().split())\nl=[]\nid_list=[]\nfor i in range(m):\n obj = list(map(int, input().split()))\n obj.append(i+1)\n l.append(obj)\nl=sorted(l, key=itemgetter(0,1))\nidx=0\nfor j in range(m):\n id_obj=[]\n if j == 0:\n idx=1\n else:\n\n if l[j][0] == l[j-1][0]:\n idx+=1\n else:\n idx =1\n id_obj.append(l[j][2])\n id_obj.append(str(l[j][0]).zfill(6)+str(idx).zfill(6))\n id_list.append(id_obj)\nid_list = sorted(id_list)\nfor k in range(m):\n print(id_list[k][1])']
['Wrong Answer', 'Accepted']
['s620916485', 's830949290']
[41464.0, 46544.0]
[667.0, 1063.0]
[372, 511]
p03221
u383196771
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\nnum = {}\nfor i in range(M):\n P_i, Y_i = map(int, input().split())\n if P_i in num:\n num[P_i].append((Y_i, i))\n else:\n num[P_i] = [(Y_i, i)]\n\ndisplay = [0] * M\nfor i in num.keys():\n k = str(0) * (6 - len(str(i))) + str(i)\n for index, j in enumerate(sorted(num[i], key=lambda x: x[0])):\n l = str(0) * (6 - len(str(index))) + str(index + 1)\n print(i, j)\n display[j[1]] = k + l\n\nfor item in display:\n print(item)', 'N, M = map(int, input().split())\n\nnum = {}\nfor i in range(M):\n P_i, Y_i = map(int, input().split())\n if P_i in num:\n num[P_i].append((Y_i, i))\n else:\n num[P_i] = [(Y_i, i)]\n\ndisplay = [0] * M\nfor i in num:\n k = str(0) * (6 - len(str(i))) + str(i)\n for index, j in enumerate(sorted(num[i], key=lambda x: x[0])):\n l = str(0) * (6 - len(str(index + 1))) + str(index + 1)\n display[j[1]] = k + l\n\nfor item in display:\n print(item)']
['Wrong Answer', 'Accepted']
['s504132873', 's953137610']
[45420.0, 42972.0]
[1122.0, 945.0]
[494, 471]
p03221
u384261199
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\nimport numpy as np\n\nN,M = map(int, input().split())\npy = [[int(i) for i in input().split()] for i in range(M)]\n\npref_dic = {}\nfor i in range(N):\n pref_dic[i+1] = []\nfor e,index in zip(py, range(M)):\n pref = e[0]\n year = e[1]\n \n pref_dic[pref].append((index, year))\n \ncity_num_dic = {}\nfor pref in pref_dic.keys():\n pref_string = str(pref)\n if len(pref_string) < 6:\n while len(pref_string) < 6:\n pref_string = "0" + pref_string\n \n in_year_list = np.array(pref_dic[pref])\n if len(in_year_list) == 0:\n continue\n \n year_ = in_year_list[:, 1]\n city_ = in_year_list[:, 0]\n \n hayaijun_ind = np.argsort(year_)\n for index, i in zip(hayaijun_ind, range(len(hayaijun_ind))):\n city_name = city_[index]\n num = str(i+1)\n if len(num) < 7:\n while len(num) < 7:\n num = "0" + num\n city_num_dic[city_name] = pref_string + num\n\n\nfor city in np.sort(list(city_num_dic.keys())):\n print(city_num_dic[city])', 'import numpy as np\n\nN,M = map(int, input().split())\npy = [[int(i) for i in input().split()] for i in range(M)]\n\npref_dic = {}\nfor i in range(N):\n pref_dic[i+1] = []\nfor e,index in zip(py, range(M)):\n pref = e[0]\n year = e[1]\n \n pref_dic[pref].append((index, year))\n \ncity_num_dic = {}\nfor pref in pref_dic.keys():\n pref_string = str(pref)\n if len(pref_string) < 6:\n while len(pref_string) < 6:\n pref_string = "0" + pref_string\n \n in_year_list = np.array(pref_dic[pref])\n if len(in_year_list) == 0:\n continue\n \n year_ = in_year_list[:, 1]\n city_ = in_year_list[:, 0]\n \n hayaijun_ind = np.argsort(year_)\n for index, i in zip(hayaijun_ind, range(len(hayaijun_ind))):\n city_name = city_[index]\n num = str(i+1)\n if len(num) < 6:\n while len(num) < 6:\n num = "0" + num\n city_num_dic[city_name] = pref_string + num\n\n\nfor city in np.sort(list(city_num_dic.keys())):\n print(city_num_dic[city])']
['Wrong Answer', 'Accepted']
['s834193482', 's936995610']
[79864.0, 84728.0]
[1913.0, 1860.0]
[1029, 1021]
p03221
u386782537
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\nlength = [list(map(int,input().split())) for _ in range(M)]\nfor i in range(M):\n length[i].insert(2,i)\nlength = sorted(length)\nprint(length)\nans_list =[0]*M\ncount = 1\nfor i in range(M):\n if i == 0:\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\n elif i >= 1 and length[i][0] == length[i-1][0]:\n count += 1\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\n elif i >= 1 and length[i][0] != length[i-1][0]:\n count = 1\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\nans_list.sort(key=lambda x: x[0])\nfor i in range(M):\n print(ans_list[i][1])\n', 'N, M = map(int, input().split())\nlength = [list(map(int,input().split()).append(i)) for _ in range(M)]\nprint(length)', 'N, M = map(int, input().split())\n\n\nlength = [list(map(int,input().split())) for _ in range(M)]\nfor i in range(M):\n length[i].insert(2,i)\nlength = sorted(length)\nans_list =[0]*M\ncount = 1\nfor i in range(M):\n if i == 0:\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\n elif i >= 1 and length[i][0] == length[i-1][0]:\n count += 1\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\n elif i >= 1 and length[i][0] != length[i-1][0]:\n count = 1\n ans = str(length[i][0]).zfill(6) + str(count).zfill(6)\n ans_list[i] = [length[i][2],ans]\nans_list.sort(key=lambda x: x[0])\nfor i in range(M):\n print(ans_list[i][1])\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s550983690', 's668634580', 's501387558']
[51544.0, 3060.0, 45612.0]
[1066.0, 17.0, 1006.0]
[728, 116, 714]
p03221
u386819480
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\nimport sys\n\n\ndef solve(N: int, M: int, P: "List[int]", Y: "List[int]"):\n a = sorted([[P[i], Y[i]] for i in range(M)], key=lambda x:(x[0],x[1]))\n \n ans = []\n t = -1\n c = 0\n for p,y in a:\n if(p != t):\n t = 0\n c += 1\n ans.append(str(p).zfill(6)+str(c).zfill(6))\n\n for i in ans:\n print(i)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n P = [int()] * (M) # type: "List[int]" \n Y = [int()] * (M) # type: "List[int]" \n for i in range(M):\n P[i] = int(next(tokens))\n Y[i] = int(next(tokens))\n solve(N, M, P, Y)\n\nif __name__ == \'__main__\':\n main()\n', "n, m = (int(_) for _ in input().split())\ne = [[int(i) for i in input().split()] for i in range(m)]\n\na_dict = {}\nfor pi,yi in e:\n if(pi not in a_dict):\n a_dict[pi] = [yj]\n else:\n a_dict[pi] +=[yj]\n\nfor pi,yi in e:\n print('{0:06d}'.format(pi)+'{0:06d}'.format(a_dict[pi].index(yi)+1))", "n, m = (int(_) for _ in input().split())\ne = [[int(i) for i in input().split()] for i in range(m)]\n\na_dict = {}\nfor pi,yi in e:\n if(pi not in a_dict):\n a_dict[pi] = [yi]\n else:\n a_dict[pi] += [yi]\n\nfor v in a_dict.values():\n print(v)\n\nfor pi,yi in e:\n print('{0:06d}'.format(pi)+'{0:06d}'.format(a_dict[pi].index(yi)+1))", "n, m = (int(_) for _ in input().split())\n# p,y = ((int(i) for i in input().split()) for j in range(n))\ne = [[int(i) for i in input().split()] for i in range(m)]\np = [i[0] for i in e]\n\ncl = list(set(p))\ncp = [p.count(cl[i]) for i in range(len(cl))]\n\nprint(cl)\nprint(cp)\n\nfor i in range(len(cl)):\n for j in range(1,cp[i]+1):\n print('{0:06d}'.format(cl[i])+'{0:06d}'.format(j))", '#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, M: int, P: "List[int]", Y: "List[int]"):\n a = sorted([[P[i], Y[i]] for i in range(M)], key=lambda x:(x[0],x[1]))\n \n ans = []\n t = -1\n c = 0\n for p,y in a:\n if(p != t):\n t = p\n c = 0\n c += 1\n ans.append(str(p).zfill(6)+str(c).zfill(6))\n\n for i in ans:\n print(i)\n\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n P = [int()] * (M) # type: "List[int]" \n Y = [int()] * (M) # type: "List[int]" \n for i in range(M):\n P[i] = int(next(tokens))\n Y[i] = int(next(tokens))\n solve(N, M, P, Y)\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\nimport bisect\n\ndef solve(N: int, M: int, P: "List[int]", Y: "List[int]"):\n \n val = [[] for i in range(N+1)]\n for pi, yi in [[P[i], Y[i]] for i in range(M)]:\n val[pi].append(yi)\n\n for i in val:\n i.sort()\n\n\n a = sorted([[P[i], Y[i]] for i in range(M)], key=lambda x:(x[0],x[1]))\n\n for p, y in [[P[i], Y[i]] for i in range(M)]:\n c_id = bisect.bisect_left(val[p], y)\n print(str(p).zfill(6)+str(c_id+1).zfill(6))\n \n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n P = [int()] * (M) # type: "List[int]" \n Y = [int()] * (M) # type: "List[int]" \n for i in range(M):\n P[i] = int(next(tokens))\n Y[i] = int(next(tokens))\n solve(N, M, P, Y)\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s165635847', 's239249171', 's552588887', 's624544218', 's854279934', 's444990963']
[30060.0, 21168.0, 39268.0, 28144.0, 30128.0, 44944.0]
[448.0, 309.0, 2105.0, 2105.0, 441.0, 671.0]
[1028, 305, 346, 384, 1046, 1166]
p03221
u388697579
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# your code goes here\ndef main():\n\tbuf = input().split()\n\tn = int(buf[0])\n\tm = int(buf[1])\n\t\n\tpy = np.zeros((m, 4), dtype="int")#num, p, year, num in p\n\tfor i in range(m):\n\t\tpy[i][0] = i+1#################\n\t\tbuf = input().split()\n\t\tpy[i][1] = int(buf[0])\n\t\tpy[i][2] = int(buf[1])\n\t\t\n\tpy = np.array(sorted(py, key=lambda x:(x[1],x[2])))\n\tbufp = 0\n\tfor i in range(m):\n\t\tif(py[i][1] != bufp):\n\t\t\tbufp = py[i][1]\n\t\t\tpy[i][3] = 1#1-origin\n\t\telse:\n\t\t\tpy[i][3] = py[i-1][3]+1\n\t#py = np.sort(py, axis=0)\n\tpy = py[np.argsort(py[:, 0])]\n\t\n\tprint(py)\n\tfor i in range(m):\n\t\tans = "{0:06d}".format(py[i][1])+"{0:06d}".format(py[i][3])\n\t\tprint(ans)\n\t\nmain()', 'import numpy as np\n# your code goes here\ndef main():\n\tbuf = input().split()\n\tn = int(buf[0])\n\tm = int(buf[1])\n\t\n\tpy = np.zeros((m, 4), dtype="int")#num, p, year, num in p\n\tfor i in range(m):\n\t\tpy[i][0] = i+1#################\n\t\tbuf = input().split()\n\t\tpy[i][1] = int(buf[0])\n\t\tpy[i][2] = int(buf[1])\n\t\t\n\tpy = np.array(sorted(py, key=lambda x:(x[1],x[2])))\n\tbufp = 0\n\tfor i in range(m):\n\t\tif(py[i][1] != bufp):\n\t\t\tbufp = py[i][1]\n\t\t\tpy[i][3] = 1#1-origin\n\t\telse:\n\t\t\tpy[i][3] = py[i-1][3]+1\n\t#py = np.sort(py, axis=0)\n\tpy = py[np.argsort(py[:, 0])]\n\t\n#\tprint(py)\n\tfor i in range(m):\n\t\tans = "{0:06d}".format(py[i][1])+"{0:06d}".format(py[i][3])\n\t\tprint(ans)\n\t\nmain()']
['Wrong Answer', 'Accepted']
['s963460462', 's425897303']
[42712.0, 42716.0]
[1429.0, 1464.0]
[662, 663]
p03221
u388927326
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\nclass City:\n def __init__(self, i1, p, y, o=None):\n self.i1 = i1\n self.p = p\n self.y = y\n self.o = o\n\n def __repr__(self):\n return f"City({self.i1}, {self.p}, {self.y}, {self.o})"\n\n def get_id(self):\n return f"{self.p:06}{self.o:06}"\n\ndef put_ids(n, cities):\n years = {i: [] for i in range(1, n + 1)}\n for c in cities:\n years[c.p].append(c.y)\n\n year_to_order = {i: {} for i in range(1, n + 1)}\n for i in range(1, n + 1):\n ys = sorted(years[i])\n for j0, y in enumerate(ys):\n year_to_order[i][y] = j0 + 1\n\n for c in cities:\n c.o = year_to_order[c.p][c.y]\n\ndef main():\n n, m = map(int, input().split())\n cities = []\n for i0 in range(m):\n p, y = map(int, input().split())\n city = City(i0, p, y)\n cities.append(city)\n put_ids(n, cities)\n # for c in cities:\n # print(c.get_id())\n\nmain()\n', '#!/usr/bin/env python3\n\nclass City:\n def __init__(self, i1, p, y, o=None):\n self.i1 = i1\n self.p = p\n self.y = y\n self.o = o\n\n \n # return f"City({self.i1}, {self.p}, {self.y}, {self.o})"\n\n def get_id(self):\n return "%06d%06d" % (self.p, self.o)\n\ndef put_ids(n, cities):\n years = {i: [] for i in range(1, n + 1)}\n for c in cities:\n years[c.p].append(c.y)\n\n year_to_order = {i: {} for i in range(1, n + 1)}\n for i in range(1, n + 1):\n ys = sorted(years[i])\n for j0, y in enumerate(ys):\n year_to_order[i][y] = j0 + 1\n\n for c in cities:\n c.o = year_to_order[c.p][c.y]\n\ndef main():\n n, m = map(int, input().split())\n cities = []\n for i0 in range(m):\n p, y = map(int, input().split())\n city = City(i0, p, y)\n cities.append(city)\n put_ids(n, cities)\n for c in cities:\n print(c.get_id())\n\nmain()\n']
['Runtime Error', 'Accepted']
['s678669920', 's180666345']
[2940.0, 110692.0]
[18.0, 800.0]
[953, 957]
p03221
u391875425
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 read():\n return int(input())\n\ndef reads():\n return list(map(int, input().split()))\n\nn,m = reads()\ncnt = {k:[] for k in range(n+1)}\nbuf = [None]*m\nfor i in range(m):\n p,y = reads()\n cnt[p].append((y,i))\nfor p,l in cnt.items():\n if not l:\n continue\n l.sort()\n print(l)\n for j,(y,i) in enumerate(l):\n buf[i] = '{:06d}{:06d}'.format(p,j+1)\n\nprint('\\n'.join(buf))", "def read():\n return int(input())\n\ndef reads():\n return list(map(int, input().split()))\n\nn,m = reads()\ncnt = {k:[] for k in range(n+1)}\nbuf = [0]*m\nfor i in range(m):\n p,y = reads()\n cnt[p].append((y,i))\nfor p,l in cnt.items():\n if not l:\n continue\n l.sort()\n print(l)\n for j,(y,i) in enumerate(l):\n buf[i] = '{:06d}{:06d}'.format(p,j+1)\n \nprint('\\n'.join(buf))", "def read():\n return int(input())\n\ndef reads():\n return list(map(int, input().split()))\n\nn,m = reads()\ncnt = {k:[] for k in range(n+1)}\nbuf = [None]*m\nfor i in range(m):\n p,y = reads()\n cnt[p].append((y,i))\nfor p,l in cnt.items():\n if not l:\n continue\n l.sort()\n for j,(y,i) in enumerate(l):\n buf[i] = '{:06d}{:06d}'.format(p,j+1)\n\nprint('\\n'.join(buf))"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s817875139', 's895085354', 's465471639']
[56460.0, 56460.0, 53088.0]
[859.0, 928.0, 677.0]
[400, 405, 387]
p03221
u393224521
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 = [[] for i in range(N)]\n\nfor i in range(M):\n p, y = map(int, input().split())\n D[p-1].append((y, i)) \nprint(D)\nans = [None]*M\n\nfor i, d in enumerate(D): \n d.sort()\n print(d)\n for k, (y, j) in enumerate(d): \n ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6) \n\nprint(*ans, sep = '\\n') ", "N, M = map(int, input().split())\nD = [[] for i in range(N)]\n\nfor i in range(M):\n p, y = map(int, input().split())\n D[p-1].append((y, i)) \n\nans = [None]*M\n\nfor i, d in enumerate(D): \n d.sort()\n for k, (y, j) in enumerate(d): \n ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6) \n\nprint(*ans, sep = '\\n') "]
['Wrong Answer', 'Accepted']
['s802617057', 's565649207']
[41672.0, 37480.0]
[884.0, 617.0]
[690, 671]
p03221
u397531548
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['import bisect\nN,M=map(int,input().split())\nA=[[] for j in range(N)]\npx=[]\nfor i in range(M):\n p,x=map(int,input().split())\n A[p-1].append(x)\n px.append([p,x])\nfor m in range(N):\n A[m].sort()\nfor k in range(M):\n q=bisect.bisect_left(A[px[k][0]-1],px[k][1])\n print("0"*(6-len(str(px[k][1])))+str(px[k][0])+"0"*(6-len(str(q)))+str(q+1))\n ', 'import bisect\nN,M=map(int,input().split())\nA=[[0] for j in range(N)]\npx=[]\nfor i in range(M):\n p,x=map(int,input().split())\n A[p-1].append(x)\n px.append([p,x])\nfor m in range(N):\n A[m].sort()\nfor k in range(M):\n q=bisect.bisect_left(A[px[k][0]-1],px[k][1])\n print("0"*(6-len(str(px[k][0])))+str(px[k][0])+"0"*(6-len(str(q)))+str(q))']
['Wrong Answer', 'Accepted']
['s386291185', 's629351300']
[32648.0, 32732.0]
[755.0, 820.0]
[360, 350]
p03221
u400738660
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 = input().split()\nplist = []\nylist = []\nn = int(n)\nm = int(m)\nanslist = [0 for i in range(m)]\nlist = [[] for i in range(n+1)]\nfor i in range(m):\n p,y = input().split()\n p = int(p)\n y = int(y)\n plist.append(p)\n ylist.append(y)\nfor i in range(m):\n for j in range(n+1):\n if plist[i] == j + 1:\n list[j].append([ylist[i],i])\nfor i in range(n):\n list[i].sort()\nfor i in range(n):\n for j in range(len(list[i])):\n mtem = list[i][j][1]\n ans1 = str(plist[mtem])\n while len(ans1) <= 6:\n ans1 = "0" + ans1\n ans2 = str(j+1)\n while len(ans2) <= 6:\n ans2 = "0" + ans2\n anslist[mtem] = ans1 + ans2\nfor i in range(m):\n print(anslist[i])', 'n,m = input().split()\nplist = []\nylist = []\nn = int(n)\nm = int(m)\nanslist = [0 for i in range(m)]\nlist = [[] for i in range(n+1)]\nfor i in range(m):\n p,y = input().split()\n p = int(p)\n y = int(y)\n plist.append(p)\n ylist.append(y)\n list[p-1].append([ylist[i],i])\nfor i in range(n):\n list[i].sort()\n for j in range(len(list[i])):\n mtem = list[i][j][1]\n ans1 = str(plist[mtem])\n while len(ans1) < 6:\n ans1 = "0" + ans1\n ans2 = str(j+1)\n while len(ans2) < 6:\n ans2 = "0" + ans2\n anslist[mtem] = ans1 + ans2\nfor i in range(m):\n print(anslist[i])\n ']
['Wrong Answer', 'Accepted']
['s525849279', 's937730747']
[29844.0, 43788.0]
[2105.0, 832.0]
[732, 644]
p03221
u401487574
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([p,y])\nls.sort(key= lambda x:x[1])\nls.sort(key= lambda x:x[0])\npre = ls[0][0]\ncnt = 1\nfor p,y in ls:\n if p==pre:\n print(str(p).zfill(6) + str(cnt).zfill(6))\n cnt+=1\n else:\n pre = p\n print(str(p).zfill(6) + str(1).zfill(6))\n cnt=2\n', '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(key= lambda x:x[1])\nls.sort(key= lambda x:x[0])\npre = ls[0][0]\ncnt = 1\nans = []\nfor p,y,i in ls:\n if p==pre:\n ans.append( (str(p).zfill(6) + str(cnt).zfill(6) ,i))\n cnt+=1\n else:\n pre = p\n ans.append((str(p).zfill(6) + str(1).zfill(6),i))\n cnt=2\nans.sort(key=lambda x:x[1])\nfor a,i in ans:\n print(a)\n']
['Wrong Answer', 'Accepted']
['s960201258', 's172281023']
[21632.0, 39336.0]
[633.0, 767.0]
[378, 470]
p03221
u404676457
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()))\n\npy = []\n\nfor i in range(m):\n py.append(input().split())\n\nmapa ={}\n\nfor i in range(m):\n if py[i][0] in mapa:\n mapa[py[i][0]][py[i][1]] = i\n else:\n mapa[py[i][0]] = {py[i][1]:i}\n\nans = ['' for _ in range(m)]\n\nfor i in mapa:\n pri = mapa[i]\n pri = sorted(pri.items())\n for j in range(len(pri)):\n ans[pri[j][1]] = ('00000' + i)[-5:] + ('00000' + str(j + 1))[-5:]\nfor i in ans:\n print(i)", "(n, m) = list(map(int, input().split()))\n\npy = []\n\nfor i in range(m):\n py.append(list(map(int, input().split())))\n\nmapa ={}\n\nfor i in range(m):\n if py[i][0] in mapa:\n mapa[py[i][0]][py[i][1]] = i\n else:\n mapa[py[i][0]] = {py[i][1]:i}\n\nans = ['' for _ in range(m)]\n\nfor i in mapa:\n pri = mapa[i]\n pri = sorted(pri.items())\n print(pri)\n for j in range(len(pri)):\n ans[pri[j][1]] = ('000000' + str(i))[-6:] + ('000000' + str(j + 1))[-6:]\nfor i in ans:\n print(i)", "(n, m) = list(map(int, input().split()))\n\npy = []\n\nfor i in range(m):\n py.append(list(map(int, input().split())))\n\nmapa ={}\n\nfor i in range(m):\n if py[i][0] in mapa:\n mapa[py[i][0]][py[i][1]] = i\n else:\n mapa[py[i][0]] = {py[i][1]:i}\n\nans = ['' for _ in range(m)]\n\nfor i in mapa:\n pri = mapa[i]\n pri = sorted(pri.items())\n for j in range(len(pri)):\n ans[pri[j][1]] = ('000000' + str(i))[-6:] + ('000000' + str(j + 1))[-6:]\nfor i in ans:\n print(i)"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s072206038', 's377373057', 's600186850']
[80316.0, 76888.0, 74876.0]
[649.0, 988.0, 767.0]
[465, 503, 488]
p03221
u414430923
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()))\ninfo = [list(map(int, input().split())) for i in range(m)]\n\npref = {}\nfor p,y in info:\n if not p in pref: pref[p] = [y]\n else: pref[p].append(y)\n\nid = {}\nfor p,years in pref.items():\n id[p] = {}\n for i,y in enumerate(years):\n id[p][y] = str(p).zfill(6) + str(i+1).zfill(6)\n\nfor p,y in info:\n print(id[p][y])', 'import numpy as np\nn,m = list(map(int, input().split()))\ninfo = [list(map(int, input().split())) for i in range(m)]\n\ninfo = np.array(info)\npref = {}\nfor i in range(1,n+1):\n pref[i] = info[info[:,0] == i, 1]\n\nid = {}\nfor p,years in pref.items():\n id[p] = {}\n for i,y in enumerate(years):\n id[p][y] = str(p).zfill(6) + str(i+1).zfill(6)\n\nfor p,y in info:\n print(id[p][y])', 'n,m = list(map(int, input().split()))\ninfo = [list(map(int, input().split())) for i in range(m)]\n\npref = {}\nfor p,y in info:\n if not p in pref: pref[p] = [y]\n else: pref[p].append(y)\n\nid = {}\nfor p,years in pref.items():\n years.sort()\n id[p] = {}\n for i,y in enumerate(years):\n id[p][y] = str(p).zfill(6) + str(i+1).zfill(6)\n\nfor p,y in info:\n print(id[p][y])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s183775258', 's226902352', 's553480553']
[83464.0, 72896.0, 83460.0]
[778.0, 2109.0, 729.0]
[367, 388, 384]
p03221
u416758623
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)]\npy.sort(key=lambda x: [x[0], x[1]])\nans = []\nP = [0] * (n + 1)\nfor p, y, i in py:\n P[p] += 1\n tmp = str(p).zfill(6) + str(P[p]).zfill(6)\n ans.append([i,tmp])\nans.sort()\nfor i,a in ans:\n print(a)', 'n,m = map(int, input().split())\npy = [list(map(int, input().split())) + [i] for i in range(m)]\npy.sort(key=lambda x: [x[0], x[1]])\nans = []\nP = [0] * (n + 1)\nfor p, y, i in py:\n P[p] += 1\n tmp = str(p).zfill(6) + str(P[p]).zfill(6)\n ans.append([i,tmp])\nans.sort()\nfor i,a in ans:\n print(a)']
['Runtime Error', 'Accepted']
['s625502623', 's062990338']
[46368.0, 42280.0]
[870.0, 937.0]
[303, 301]
p03221
u422104747
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['import bisect\nn,m = map(int,input().split())\n\nl1 = [[] for i in range(n)]\nl2 = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n l1[p-1].append(y)\n l2.append((p,y))\n\nfor p in range(n):\n l1[p].sort()\n\nfor i in range(m):\n p = l2[i][0]\n k = bisect.right(l1[p-1],l2[i][1])\n p = str(p)\n k = str(k)\n ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k\n print(ans)\n', 'import bisect\nn,m = map(int,input().split())\n\nl1 = [[] for i in range(n)]\nl2 = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n l1[p-1].append(y)\n l2.append((p,y))\n\nfor p in range(n):\n l1[p].sort()\n\nfor i in range(m):\n p = l2[i][0]\n k = bisect.bisect_right(l1[p-1],l2[i][1])\n p = str(p)\n k = str(k)\n ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k\n print(ans)']
['Runtime Error', 'Accepted']
['s754105408', 's214850960']
[28196.0, 29604.0]
[413.0, 660.0]
[382, 388]
p03221
u423585790
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\nfrom collections import defaultdict\nfrom collections import deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\nimport itertools\nsys.setrecursionlimit(10**5)\nstdin = sys.stdin\ndef LI(): return list(map(int, stdin.readline().split()))\ndef LF(): return list(map(float, stdin.readline().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))\ndef II(): return int(stdin.readline())\ndef IF(): return float(stdin.readline())\ndef LS(): return list(map(list, stdin.readline().split()))\ndef S(): return list(stdin.readline().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\n\n#A\ndef A():\n return\n\n#B\ndef B():\n return\n\n#C\ndef C():\n n, m = LI()\n py = LIR(m)\n city = [[] for i in range(n)]\n for p, y in py:\n city[p-1].append(y)\n city[p-1].sort()\n for p, y in py:\n a = "00000" + str(p)\n a = a[-5:]\n b = "00000" + str(city[p-1].index(y) + 1)\n b = b[-5:]\n print(a+b) \n return\n\n#D\ndef D():\n return\n\n#E\ndef E():\n return\n\n#F\ndef F():\n return\n\n#G\ndef G():\n return\n\n#H\ndef H():\n return\n\n#Solve\nif __name__ == \'__main__\':\n C()\n', '#!usr/bin/env python3\nfrom collections import defaultdict\nfrom collections import deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\nimport itertools\nsys.setrecursionlimit(10**5)\nstdin = sys.stdin\ndef LI(): return list(map(int, stdin.readline().split()))\ndef LF(): return list(map(float, stdin.readline().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))\ndef II(): return int(stdin.readline())\ndef IF(): return float(stdin.readline())\ndef LS(): return list(map(list, stdin.readline().split()))\ndef S(): return list(stdin.readline().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\n\n#A\ndef A():\n return\n\n#B\ndef B():\n return\n\n#C\ndef C():\n n, m = LI()\n py = LIR(m)\n pya = py[::1]\n py.sort(key=lambda x: x[1])\n city = [1 for i in range(n)]\n dicity = {}\n for p, y in py:\n dicity[(p,y)] = city[p-1]\n city[p-1] += 1 \n for p, y in pya:\n a = "00000" + str(p)\n a = a[-6:]\n b = "00000" + str(dicity[(p, y)])\n b = b[-6:]\n print(a+b)\n\n return\n\n#D\ndef D():\n return\n\n#E\ndef E():\n return\n\n#F\ndef F():\n return\n\n#G\ndef G():\n return\n\n#H\ndef H():\n return\n\n#Solve\nif __name__ == \'__main__\':\n C()\n']
['Wrong Answer', 'Accepted']
['s999015026', 's083518082']
[36872.0, 47300.0]
[2106.0, 536.0]
[1475, 1538]
p03221
u426501657
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 = []\n\nIndexs = []\nSyuturyoku = []\n\n\nfor j in range(N):\n\tP.append([0])\n\n\nfor i in range(M):\n\tp,y = map(int,input().split())\n\n\tP[p-1].append(y)\n\tIndexs.append(y)\n\tSyuturyoku.append(("0","0"))\n\nfor i in range(len(P)):\n\tP[i].sort()\n\tP[i] = list(map(str,P[i]))\n\n\nfor i in range(len(P)):\n\tif(len(P[i])>1):\n\t\tfor j in range(len(P[i])-1):\n\t\t\tatai = P[i][j+1]\n\t\t\tsi = i+1\n\t\t\tsi = str(si)\n\t\t\tx = j+1\n\t\t\tx = str(x)\n\t\t\tbangou = list(map(str,si))\n\t\t\tbangou_len = int(len(bangou))\n\t\t\tbangou_ushiro = list(map(str,x))\n\t\t\tbangou_ushiro_len = int(len(bangou_ushiro))\n\t\t\tif(len(bangou)<6):\n\t\t\t\tfor zero in range(6-bangou_len):\n\t\t\t\t\tbangou.insert(0,\'0\')\n\t\t\tif(len(bangou_ushiro)<6):\n\t\t\t\tfor zero in range(6-bangou_ushiro_len):\n\t\t\t\t\tbangou_ushiro.insert(0,\'0\')\n\n\t\t\tmojiretsu = \'\'\n\t\t\tfor k in bangou:\n\t\t\t\tmojiretsu += k\n\t\t\tmojiretsu2 = \'\'\n\t\t\tfor k2 in bangou_ushiro:\n\t\t\t\tmojiretsu2 += k2\n\n\t\t\ta = Indexs.index(int(atai))\n\t\t\tSyuturyoku[a] = (mojiretsu,mojiretsu2)\nfor i in range(M):\n\tprint(Syuturyoku[i][0],Syuturyoku[i][1])\n', 'N,M = map(int,input().split())\nP = []\n\nIndexs = []\nSyuturyoku = []\n\n\nfor j in range(N):\n\tP.append([0])\n\n\nfor i in range(M):\n\tp,y = map(int,input().split())\n\n\tP[p-1].append(y)\n\tIndexs.append(y)\n\tSyuturyoku.append(("0","0"))\n\nfor i in range(len(P)):\n\tP[i].sort()\n\tP[i] = list(map(str,P[i]))\n\n\nfor i in range(len(P)):\n\tif(len(P[i])>1):\n\t\tzeros = \'\'\n\t\tzeros_2 = \'\'\n\t\tfor j in range(len(P[i])-1):\n\t\t\tatai = P[i][j+1]\n\t\t\tsi = i+1\n\t\t\tsi = str(si)\n\t\t\tx = j+1\n\t\t\tx = str(x)\n\t\t\tbangou = list(map(str,si))\n\t\t\tbangou_len = int(len(bangou))\n\t\t\tbangou_ushiro = list(map(str,x))\n\t\t\tbangou_ushiro_len = int(len(bangou_ushiro))\n\t\t\tif(len(bangou)<6):\n\t\t\t\tfor zero in range(6-bangou_len):\n\t\t\t\t\tzeros += \'0\'\n\t\t\tif(len(bangou_ushiro)<6):\n\t\t\t\tfor zero in range(6-bangou_ushiro_len):\n\t\t\t\t\tzeros_2 += \'0\'\n\n\t\t\tmojiretsu = zeros+si\n\t\t\tmojiretsu2 = zeros_2+x\n\n\t\t\ta = Indexs.index(int(atai))\n\t\t\tSyuturyoku[a] = (mojiretsu,mojiretsu2)\nfor i in range(M):\n\tprint(Syuturyoku[i][0]+Syuturyoku[i][1])\n', "import bisect\n\nN,M = map(int,input().split())\nP = []\n\nIndexs = {}\nSyuturyoku = []\nvp = []\nvy = []\n\nfor j in range(N):\n\tP.append([0])\n\n\nfor i in range(M):\n\tp,y = map(int,input().split())\n\tvp.append(p)\n\tvy.append(y)\n\n\tP[p-1].append(y)\n\tIndexs[y] = i\n\tSyuturyoku.append(0)\n\nfor i in range(len(P)):\n\tP[i].sort()\n\nfor si in range(M):\n\tx = bisect.bisect_left(P[vp[si] - 1], vy[si])\n\tprint('{:06}{:06}'.format(vp[si], x)) \n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s046473874', 's315710954', 's962118209']
[39640.0, 46924.0, 38136.0]
[2106.0, 2106.0, 702.0]
[1035, 967, 416]
p03221
u427344224
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\nshi_map = []\n\nfor i in range(M):\n p, y = map(int, input().split())\n shi_map.append([i, p, y])\n\nshi_map = sorted(shi_map, key=lambda x: (x[1], x[2]))\nprint(shi_map)\n\nresult = {}\nshi_count = {}\nfor i, p, y in shi_map:\n\n if p in shi_count:\n c = shi_count[p]\n count = c + 1\n shi_count[p] = count\n else:\n shi_count[p] = 1\n count = 1\n result[i] = [p, count]\nresult = list(sorted(result.items(), key=lambda x: x[0]))\n\nfor i, p in result:\n\n p2 = str(p[0]).zfill(6)\n\n y = str(p[1]).zfill(6)\n r = p2+y\n print(r)', 'N, M = map(int, input().split())\nitems = []\nfor i in range(M):\n p, y = map(int, input().split())\n items.append((p, y, i))\n\nitems = sorted(items, key=lambda x:(x[0], x[1]))\n\nans = {}\n\nken = -1\ncnt = 1\nfor item in items:\n if item[0] != ken:\n cnt = 1\n ans[item[2]] = str(item[0]).zfill(6) + str(cnt).zfill(6)\n ken = item[0]\n else:\n cnt += 1\n ans[item[2]] = str(item[0]).zfill(6) + str(cnt).zfill(6)\n\nfor i in range(M):\n print(ans[i])\n']
['Wrong Answer', 'Accepted']
['s230321393', 's282900407']
[55548.0, 36180.0]
[1073.0, 683.0]
[597, 481]
p03221
u432333240
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["N, M = map(int,input().split())\nP_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')\nyears = [np.sort(P_Y_list[np.where(P_Y_list[:,0]==i)][:,1]) for i in set(P_Y_list[:, 0])]\nfor l in P_Y_list:\n left = str(l[0]).zfill(6)\n right = str(np.where(years[list(set(P_Y_list[:,0])).index(l[0])]==l[1])[0][0]+1).zfill(6)\n print(left+right)", "import numpy as np\nN, M = map(int,input().split())\nP_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')\ncounts = (np.zeros(N+1)).astype(int)\nid_list = []\n\nsort_ind = np.argsort(P_Y_list[:,1])\nsorted_P_Y = P_Y_list[sort_ind]\n\nfor p, y in sorted_P_Y:\n counts[p] += 1\n id_list.append(str(p).zfill(6) + str(counts[p]).zfill(6))\nid_list = np.array(id_list)\nid_list = id_list[np.argsort(sort_ind)]\nfor id in id_list:\n print(id)"]
['Runtime Error', 'Accepted']
['s926427504', 's745928877']
[3064.0, 50556.0]
[18.0, 1618.0]
[359, 450]
p03221
u434822333
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["N, M = map(int, input().split())\n\ncity = []\nfor i in range(M):\n\tp, y = map(int, input().split())\n\tcity.append([p, y, i])\ncity.sort()\n\nprint(city)\n\nout = [0]*M\ncnt = 1\nfor i in range(len(city)):\n\tout[city[i][2]] = '{0:06d}{1:06d}'.format(city[i][0], cnt)\n\ttry:\n\t\tif city[i+1][0] == city[i][0]: cnt += 1\n\t\telse: cnt = 1\n\texcept(IndexError):\n\t\tcnt += 1\n\nfor o in out:\n\tprint(o)\n\t", "N, M = map(int, input().split())\n\ncity = []\nfor i in range(M):\n\tp, y = map(int, input().split())\n\tcity.append([p, y, i])\ncity.sort()\n\nout = [0]*M\ncnt = 1\nfor i in range(len(city)):\n\tout[city[i][2]] = '{0:06d}{1:06d}'.format(city[i][0], cnt)\n\ttry:\n\t\tif city[i+1][0] == city[i][0]: cnt += 1\n\t\telse: cnt = 1\n\texcept(IndexError):\n\t\tcnt += 1\n\nfor o in out:\n\tprint(o)\n\t"]
['Wrong Answer', 'Accepted']
['s011209742', 's564648266']
[34008.0, 31300.0]
[800.0, 678.0]
[376, 363]
p03221
u440129511
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()))]\nl=[1]*n\nfor i in range(m):\n py[i].append(i+1)\npy.sort()\nfor i in range(m):\n py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))\n l[py[i][0]-1]+=1\npy.sort(key=lambda x:x[2])\nfor i in range(m):\n print(py[i][-1])', 'n,m=map(int,input().split())\npy=[list(map(int,input().split())) for _ in range(m)]\nl=[1]*n\nfor i in range(m):\n py[i].append(i+1)\npy.sort()\nfor i in range(m):\n py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))\n l[py[i][0]-1]+=1\npy.sort(key=lambda x:x[2])\nfor i in range(m):\n print(py[i][-1])']
['Runtime Error', 'Accepted']
['s389215449', 's290761400']
[3828.0, 39652.0]
[18.0, 822.0]
[302, 320]
p03221
u442877951
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\n\ninput = sys.stdin.readline\nN,M = map(int,input().split())\nPY = {n: [] for n in range(N + 1)}\nfor i in range(M):\n p,y = map(int,input().split())\n PY[p].append((y, i))\nprint(PY)\nfor p,y in PY.items():\n y.sort()\n for j, (z, i) in enumerate(y):\n top_number = '0'*(6-len(str(p)))+str(p)\n under_number = '0'*(6-len((str(j+1))))+str(j+1)\n print(top_number + under_number)", "import sys\n\ninput = sys.stdin.readline\nN,M = map(int,input().split())\nPY = {n: [] for n in range(N + 1)}\nans = [0]*M\nfor i in range(M):\n p,y = map(int,input().split())\n PY[p].append((y, i))\nprint(PY)\nfor p,y in PY.items():\n y.sort()\n for j, (z, i) in enumerate(y):\n top_number = '0'*(6-len(str(p)))+str(p)\n under_number = '0'*(6-len((str(j+1))))+str(j+1)\n ans[i] = top_number + under_number\nfor i in range(M):\n print(ans[i])", "N,M = map(int,input().split())\nPY = {n: [] for n in range(N + 1)}\nans = [0]*M\nfor i in range(M):\n p,y = map(int,input().split())\n PY[p].append((y, i))\nfor p,y in PY.items():\n y.sort()\n for j, (z, i) in enumerate(y):\n top_number = '0'*(6-len(str(p)))+str(p)\n under_number = '0'*(6-len((str(j+1))))+str(j+1)\n ans[i] = top_number + under_number\nfor i in range(M):\n print(ans[i])"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s147189206', 's443239605', 's230632275']
[44384.0, 49992.0, 44448.0]
[625.0, 639.0, 726.0]
[389, 438, 389]
p03221
u443010331
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 get_line():\n return input().split(\' \')\n\nclass element:\n def __init__(self, P, Y, idx):\n self.P = P\n self.Y = Y\n self.idx = idx\n def __lt__(self, other):\n return self.Y < other.Y\n\nN, M = map(int, get_line())\nels = [0] * M\nfor i in range(M):\n p, y = map(int, get_line())\n els[i] = Element(p, y, i)\n\np_map = [[] for _ in range(N)]\n\nfor e in els:\n p_map[e.P - 1].append(e)\n\nans = [0] * M\n\nfor mp in p_map:\n cnt = 1\n for e in sorted(mp):\n ans[e.idx] = "{:06d}{:06d}".format(e.P, cnt)\n cnt = cnt + 1\n\nfor e in ans:\n print(e)\n', 'def get_line():\n return input().split(\' \')\n\nclass element:\n def __init__(self, P, Y, idx):\n self.P = P\n self.Y = Y\n self.idx = idx\n def __lt__(self, other):\n return self.Y < other.Y\n\nN, M = map(int, get_line())\nels = [0] * M\nfor i in range(M):\n p, y = map(int, get_line())\n els[i] = element(p, y, i)\n\np_map = [[] for _ in range(N)]\n\nfor e in els:\n p_map[e.P - 1].append(e)\n\nans = [0] * M\n\nfor mp in p_map:\n cnt = 1\n for e in sorted(mp):\n ans[e.idx] = "{:06d}{:06d}".format(e.P, cnt)\n cnt = cnt + 1\n\nfor e in ans:\n print(e)\n']
['Runtime Error', 'Accepted']
['s626262481', 's113594710']
[3828.0, 50180.0]
[19.0, 1061.0]
[550, 550]
p03221
u447528293
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 year(x):\n return Y[x]\n\nN, M = [int(s) for s in input().rstrip().split()]\nP = []\nY = []\nfor m in range(M):\n input_line = [int(s) for s in input().rstrip().split()]\n P.append(input_line[0])\n Y.append(input_line[1])\n\npref = [[] for _ in range(N)]\nfor m in range(M):\n pref[P[m]-1].append(m)\n\nfor n in range(N):\n pref[n].sort(key = year)\n \nid = []\nfor m in range(M):\n str1 = '{0:06d}'.format(P[m])\n for i in range(len(pref[P[m]-1])):\n if i == m:\n str2 = '{0:06d}'.format(i+1)\n id.append(str1 + str2)\n\nfor m in range(M):\n print(id[m])", "def year(x):\n return Y[x]\n\nN, M = [int(s) for s in input().rstrip().split()]\nP = []\nY = []\nfor m in range(M):\n input_line = [int(s) for s in input().rstrip().split()]\n P.append(input_line[0])\n Y.append(input_line[1])\n\npref = [[] for _ in range(N)]\nfor m in range(M):\n pref[P[m]-1].append(m)\n\nfor n in range(N):\n if pref[n]:\n pref[n].sort(key = year)\n \nid = []\nfor m in range(M):\n str1 = '{0:06d}'.format(P[m])\n for i in range(len(pref[P[m]-1])):\n if i == m:\n str2 = '{0:06d}'.format(i+1)\n id.append(str1 + str2)\n\nfor m in range(M):\n print(id[m])", "N, M = [int(s) for s in input().rstrip().split()]\npref = [[] for _ in range(N)]\nP = []\nfor m in range(M):\n p, year = [int(s) for s in input().rstrip().split()]\n pref[p-1].append([year, m])\n P.append(p)\n\nid = [None] * M\nfor n, p in enumerate(pref):\n if not p:\n continue \n p.sort()\n for x, (year, m) in enumerate(p):\n id[m] = '{0:06d}{1:06d}'.format(n+1, x+1)\n\nprint('\\n'.join(id))\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s636968009', 's944985720', 's911368800']
[34392.0, 34408.0, 45440.0]
[2105.0, 2105.0, 676.0]
[583, 603, 415]
p03221
u447749982
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\nprefectures = [[] for i in range(N)]\n\n\nfor city in range(M):\n P, Y = map(int, input().split())\n prefectures[P-1].append(Y)\n\n\nfor prefecture, cities in enumerate(prefectures):\n if cities == []:\n continue\n else:\n cities.sort()\n \n for x, city in enumerate(cities):\n temp = '{0:06d}'.format(prefecture+1)\n temp = temp + '{0:06d}'.format(x+1)\n print(temp)\n", "N, M = map(int, input().split())\ntemp = [list(map(int, input().split())) for i in range(M)]\ncities = []\nfor x, city in enumerate(temp):\n cities.append([x+1, city[0], city[1]])\n# print(cities)\n# [[1, 1, 32], [2, 2, 63], [3, 1, 12]]\n\n\n\nprefectures = [[] for i in range(N)]\nfor city in cities:\n prefectures[city[1]-1].append(city)\n\n# [[[1, 1, 32], [3, 1, 12]], [[2, 2, 63]]]\n\nID_list = []\n\nfor prefecture in prefectures:\n prefecture.sort(key=lambda x:x[2])\n \n # [[3, 1, 12], [1, 1, 32]]\n # [[2, 2, 63]]\n for x, city in enumerate(prefecture):\n ID_list.append([city[0], city[1], x+1])\n\nID_list.sort()\n# print(ID_list)\n# [[1, 1, 2], [2, 2, 1], [3, 1, 1]]\n\n\n\nfor ID in ID_list:\n temp = '{0:06d}'.format(ID[1])\n temp = temp + '{0:06d}'.format(ID[2])\n print(temp)\n\n\n\n"]
['Wrong Answer', 'Accepted']
['s134471659', 's506950963']
[19376.0, 57864.0]
[614.0, 1184.0]
[500, 942]
p03221
u449473917
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())\n \npref = [[0] for i in range(N+1)]\nimport collections\nq = collections.deque()\n \nfor i in range(M):\n p,y = map(int, input().split())\n pref[p].append(y)\n q.append((p,y))\nfor p in pref:\n p.sort()\n \nprint(q)\nimport bisect\nfor p,y in q:\n print(p,y)\n print("%06d%06d" %(p, bisect.bisect_left(pref[p], y)))', 'import sys\ninput=sys.stdin.readline\n \nN,M = map(int, input().split())\n \npref = [[0] for i in range(N+1)]\nimport collections\nq = collections.deque()\n \nfor i in range(M):\n p,y = map(int, input().split())\n pref[p].append(y)\n q.append((p,y))\nfor p in pref:\n p.sort()\n \nimport bisect\nfor p,y in q:\n print("%06d%06d" %(p, bisect.bisect_left(pref[p], y)))']
['Wrong Answer', 'Accepted']
['s830235786', 's934252303']
[36304.0, 31084.0]
[626.0, 431.0]
[387, 363]
p03221
u450339194
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\ncounts = defaultdict(int)\nnumbers = {}\n\ncities = []\nfor i in range(M):\n p, y = map(int, input().split())\n cities.append([i, p, y])\n\nsorted_cities = sorted(cities, key=lambda x: x[2])\nfor city in sorted_cities:\n i, p, y = city\n counts[p] += 1\n numbers[i] = '{:06}{:06}'.format(p, counts[p])\n\nfor city in cities:\n print(numbers[city[0]])", "from collections import defaultdict\nN, M = map(int, input().split())\n\ncounts = defaultdict(int)\nnumbers = {}\n\ncities = []\nfor i in range(M):\n p, y = map(int, input().split())\n cities.append([i, p, y])\n\nsorted_cities = sorted(cities, key=lambda x: x[2])\nfor city in sorted_cities:\n i, p, y = city\n counts[p] += 1\n numbers[i] = '{:06}{:06}'.format(p, counts[p])\n\nfor city in cities:\n print(numbers[city[0]])"]
['Runtime Error', 'Accepted']
['s420439946', 's577980363']
[3064.0, 47324.0]
[17.0, 654.0]
[387, 423]
p03221
u450904670
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 = list(map(int, input().split()))\ncities = defaultdict(list)\ncities = [ list(map(int, input().split())) for _ in range(m)]\nsorted = sorted(\n cities,\n key = lambda x: (x[0], x[1])\n)\nhoge = 0\nfirst_code = 0\nfuga = 0\nsecond_code = 0\nfor city in sorted:\n if(hoge < city[0]):\n hoge = city[0]\n first_code += 1\n fuga = 0\n seconde_code = 0\n if(fuga < city[1]):\n fuga = city[1]\n seconde_code += 1 \n print(format(first_code, \'06\'), format(second_code, \'06\'),sep="")', 'from collections import defaultdict\nn,m = list(map(int, input().split()))\ncities = defaultdict(list)\ncities = [ list(map(int, input().split())) for _ in range(m)]\nsorted = sorted(\n cities,\n key = lambda x: (x[0], x[1])\n)\nhoge = 0\nfirst_code = 0\nfuga = 0\nsecond_code = 0\nfor city in sorted:\n if(hoge < city[0]):\n hoge = city[0]\n first_code += 1\n fuga = 0\n second_code = 0\n if(fuga < city[1]):\n fuga = city[1]\n second_code += 1 \n print(format(first_code, \'06\'), format(second_code, \'06\'),sep="")', 'n,m = list(map(int, input().split()))\ncities = defaultdict(list)\ncities = [ list(map(int, input().split())) for _ in range(m)]\nsorted = sorted(\n cities,\n key = lambda x: (x[0], x[1])\n)\nhoge = 0\nfirst_code = 0\nfuga = 0\nsecond_code = 0\nfor city in sorted:\n if(hoge < city[0]):\n hoge = city[0]\n first_code += 1\n fuga = 0\n seconde_code = 0\n if(fuga < city[1]):\n fuga = city[1]\n seconde_code += 1 \n print(format(first_code, \'06\'), format(second_code, \'06\'),sep="")', 'from collections import defaultdict\nimport heapq\nn_pref, m_city = list(map(int, input().split()))\nrecord = defaultdict(list)\ncities = []\nfor i in range(m_city):\n pref, year = list(map(int, input().split()))\n cities.append({"pref": pref, "year": year})\n heapq.heappush(record[pref], year)\nres = defaultdict(dict)\nfor key ,value in record.items():\n for i in range(1, len(value) + 1):\n res[key][heapq.heappop(value)] = i\nfor city in cities:\n print(format(city["pref"], \'06d\'), format(res[city["pref"]][city["year"]], \'06d\'), sep="")']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s041613435', 's869488246', 's928349409', 's449163407']
[36520.0, 36932.0, 3064.0, 101064.0]
[793.0, 804.0, 18.0, 1107.0]
[521, 519, 485, 537]
p03221
u452284862
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\nP = [0]*M\nY = [0]*M\n\nfor i in range(M):\n p,y = map(int,input().split())\n P.append(p)\n Y.append(y)\n\nA = [0]*M\nC = [0]*M\n\nB = [0]*M\nfor i in range(M):\n B[i] = Y[i]*100000+i\n\nB.sort()\n\nfor i in range(M):\n d = B[i] % 100000\n k = P[d] - 1\n\n C[d] = A[k]\n A[k] += 1\n\nfor i in range(M):\n print('%06d%06d' % (P[i],C[i]+1))\n", "N,M = map(int,input().split())\n\nP = [0]*M\nY = [0]*M\n\nfor i in range(M):\n p[i],y[i] = map(int,input().split())\n\nA = [0]*M\nC = [0]*M\n\nB = [0]*M\nfor i in range(M):\n B[i] = Y[i]*100000+i\n\nB.sort()\n\nfor i in range(M):\n d = B[i] % 100000\n k = P[d] - 1\n\n C[d] = A[k]\n A[k] += 1\n\nfor i in range(M):\n print('%06d%06d' % (P[i],C[i]+1))\n", "N,M = map(int,input().split())\n\nP = [0]*M\nY = [0]*M\n\nfor i in range(M):\n P[i],Y[i] = map(int,input().split())\n\nA = [0]*N\nC = [0]*M\n\nB = [0]*M\nfor i in range(M):\n B[i] = Y[i]*100000+i\n\nB.sort()\n\nfor i in range(M):\n d = B[i] % 100000\n k = P[d] - 1\n\n C[d] = A[k]\n A[k] += 1\n\nfor i in range(M):\n print('%06d%06d' % (P[i],C[i]+1))\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s564886535', 's860448536', 's267429376']
[22516.0, 4596.0, 21820.0]
[491.0, 20.0, 546.0]
[373, 347, 347]
p03221
u454524105
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())\nl = []\nfor _ in range(m):\n l.append([int(x) for x in input().split()])\nd = {}\nfor i in range(m):\n k = str(l[i][0])\n if k not in d.keys():\n d[k] = 1\n else:\n d[k] += 1\n print(k.zfill(6) + str(d[k]).zfill(6))', 'import bisect as bis\nn, m = map(int, input().split())\np, y = [], []\nidx = lambda x: x-1\nfor _ in range(m):\n p_, y_ = map(int, input().split())\n p.append(p_)\n y.append(y_)\nval = [[] for _ in range(n)]\nfor i in range(m):\n val[idx(p[i])].append(y[i])\nfor i in range(n):\n val[i].sort()\nfor i in range(m):\n v = p[i]\n id = bis.bisect_right(val[idx(v)], y[i])\n print(str(v).zfill(6) + str(id).zfill(6))']
['Wrong Answer', 'Accepted']
['s331716531', 's307220144']
[36352.0, 24120.0]
[558.0, 657.0]
[275, 419]
p03221
u455317716
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['N,M = (int(x) for x in input().split())\n\np_y_list = []\ny_count = [1]*(M+1)\n\nfor i in range(M):\n p_y_list.append([int(x) for x in input().split()])\n p_y_list[i].append(i)\np_y_list.sort(key = lambda x:x[1])\n\nfor i in p_y_list:\n i[1] = y_count[i[0]]\n y_count[i[0]] += 1\n\np_y_list.sort(key = lambda x:x[2])\nfor i in p_y_id_list:\n print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))', 'N,M = (int(x) for x in input().split())\n\np_y_list = [0]*N\ny_count = [1]*(M+1)\n\nfor i in range(N):\n p,y = (int(x) for x in input().split())\n p_y_list[i] = [p,y,i]\np_y_list.sort(key = lambda x:x[1])\n\nfor i in p_y_list:\n i[1] = y_count[i[0]]\n y_count[i[0]] += 1\n\np_y_list.sort(key = lambda x:x[2])\nfor i in p_y_list:\n print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))', 'N,M = (int(x) for x in input().split())\n\np_y_list = []\ny_count = [1]*(M+1)\n\nfor i in range(M):\n p,y = (int(x) for x in input().split())\n p_y_list[i] = [p,y,i]\np_y_list.sort(key = lambda x:x[1])\n\nfor i in p_y_list:\n i[1] = y_count[i[0]]\n y_count[i[0]] += 1\n\np_y_list.sort(key = lambda x:x[2])\nfor i in p_y_id_list:\n print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))', 'N,M = (int(x) for x in input().split())\n\np_y_list = []\n\nfor i in range(M):\n p_y_list.append(tuple(int(x) for x in input().split()))\np_y_list.sort(key = lambda x:x[1])\np_y_list.sort(key = lambda x:x[0])\n\np_y_id_list = []\np = p_y_list[0][0]\ny_c = 1\nfor i in p_y_list:\n if i[0] == p:\n p_y_id_list.append((i[0],y_c))\n y_c += 1\n else:\n p = i[0]\n y_c = 1\n p_y_id_list.append((i[0],y_c))\n\np_y_id_list.sort(key = lambda x:x[1] , reverse =True)\np_y_id_list.sort(key = lambda x:x[0] , reverse =True)\nfor i in p_y_id_list:\n print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))', 'N,M = (int(x) for x in input().split())\n\np_y_list = [0]*M\ny_count = [1]*(N+1)\n\nfor i in range(M):\n p,y = (int(x) for x in input().split())\n p_y_list[i] = [p,y,i]\np_y_list.sort(key = lambda x:x[1])\n\nfor i in p_y_list:\n i[1] = y_count[i[0]]\n y_count[i[0]] += 1\n\np_y_list.sort(key = lambda x:x[2])\nfor i in p_y_list:\n print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s172701799', 's230958973', 's360296851', 's817284172', 's669731582']
[26908.0, 26536.0, 3828.0, 29036.0, 26684.0]
[515.0, 708.0, 19.0, 790.0, 768.0]
[395, 384, 384, 614, 384]
p03221
u456033454
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.
['ken_num, city_num = map(int,input().split())\ncity_list = [None for _ in range(city_num)]\nken_list = [1 for _ in range(ken_num+1)]\nid_list = [None for _ in range(city_num)]\nfor index in range(city_num):\n city_list[index] = list(map(int,input().split()))\n city_list[index].append(index)\ncity_list = sorted(city_list, key=lambda x: x[1])\n\nfor index,city in enumerate(city_list):\n id_list[city[2]] = str(city[0]).zfill(6) + str(ken_list[city[0]]).zfill(6)\n ken_list[city[0]] += 1\n\nprint(id_list)', 'ken_num, city_num = map(int,input().split())\ncity_list = [None for _ in range(city_num)]\nken_list = [1 for _ in range(ken_num+1)]\nid_list = [None for _ in range(city_num)]\nfor index in range(city_num):\n city_list[index] = list(map(int,input().split()))\n city_list[index].append(index)\ncity_list = sorted(city_list, key=lambda x: x[1])\n\nfor index,city in enumerate(city_list):\n id_list[city[2]] = str(city[0]).zfill(6) + str(ken_list[city[0]]).zfill(6)\n ken_list[city[0]] += 1\n\nfor ans in id_list:\n print(ans)']
['Wrong Answer', 'Accepted']
['s484936358', 's640649152']
[44084.0, 41852.0]
[676.0, 768.0]
[503, 523]
p03221
u456353530
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.
['Data = list(map(int, input().split()))\nN = Data[0]\nM = Data[1]\ndel(Data)\nData = []\nfor i in range(M):\n Data.append(list(map(int, input().split())))\nData.sort()\nCnt = 0\nNum = 0\nStr = ""\nfor i in range(M):\n if Num == Data[i][0]:\n Cnt += 1\n else:\n Cnt = 1\n Num = Data[i][0]\n Str = format(Num, \'06x\') + format(Cnt, \'06x\')\n print(Str)', 'Data = list(map(int, input().split()))\nN = Data[0]\nM = Data[1]\ndel(Data)\nData = []\nfor i in range(M):\n Data.append(list(map(int, input().split())))\n Data[i].append(i)\nData.sort()\nCnt = 0\nNum = 0\nfor i in range(M):\n if Num == Data[i][0]:\n Cnt += 1\n else:\n Cnt = 1\n Num = Data[i][0]\n Data[i].append(Cnt)\nData.sort(key=lambda x:x[2])\n\nfor i in range(M):\n print(str(Data[i][0]).zfill(6) + str(Data[i][3]).zfill(6))']
['Wrong Answer', 'Accepted']
['s472750091', 's868228921']
[28816.0, 35480.0]
[830.0, 832.0]
[343, 425]
p03221
u457683760
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()]\nP=[[int(i) for i in input().split()] for j in range(m)]\n\ndef prefecturesort(i):\n return i[0]\n\ndef yearsort(i):\n return i[1]\n\nW=[0 for i in range(n)]\nZ=[]\n\nfor i in range(m):\n P[i].append(i)\n W[P[i][0]]+=1\n\nP.sort(key=prefecturesort)\nP_c=[]\nsum=0\nfor i in range(n):\n c=W[i]\n if c==0:\n P_c.append([])\n else:\n P_c.append(P[sum:c+sum])\n sum+=c\n P_c[i].sort(key=yearsort)\nfor x in P_c:\n for j in range(len(x)):\n X=str("{0:06d}".format(x[j][0]))\n Y=str("{0:06d}".format(j+1))\n Z.append([X+Y,x[j][2]])\nZ.sort(key=yearsort)\nfor i in range(m):\n print(Z[i][0])\n', 'n,m=[int(i) for i in input().split()]\nP=[[int(i) for i in input().split()] for j in range(m)]\n\ndef prefecturesort(i):\n return i[0]\n\ndef yearsort(i):\n return i[1]\n\nW=[]\nZ=[]\n\nfor i in range(m):\n P[i].append(i)\n W.append(P[i][0])\n\nP.sort(key=prefecturesort)\nP_c=[]\nsum=0\nfor i in range(n):\n P_c.append(P[sum:W.count(i+1)+sum])\n sum+=c\n P_c[i].sort(key=yearsort)\nfor x in P_c:\n for j in range(len(x)):\n X=str("{0:06d}".format(x[j][0]))\n Y=str("{0:06d}".format(j+1))\n Z.append([X+Y,x[j][2]])\nZ.sort(key=yearsort)\nfor i in range(m):\n print(Z[i][0])', 'n,m=[int(i) for i in input().split()]\nP=[[int(i) for i in input().split()] for j in range(m)]\n\ndef prefecturesort(i):\n return i[0]\n\ndef yearsort(i):\n return i[1]\n\nW=[0 for i in range(n)]\nZ=[]\n\nfor i in range(m):\n P[i].append(i)\n W[P[i][0]-1]+=1\n\nP.sort(key=prefecturesort)\nP_c=[]\nsum=0\nfor i in range(n):\n c=W[i]\n if c==0:\n P_c.append([])\n else:\n P_c.append(P[sum:c+sum])\n sum+=c\n P_c[i].sort(key=yearsort)\nfor x in P_c:\n for j in range(len(x)):\n X=str("{0:06d}".format(x[j][0]))\n Y=str("{0:06d}".format(j+1))\n Z.append([X+Y,x[j][2]])\nZ.sort(key=yearsort)\nfor i in range(m):\n print(Z[i][0])\n ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s151001916', 's309305212', 's447898195']
[52880.0, 26820.0, 53500.0]
[1273.0, 426.0, 1263.0]
[657, 591, 663]
p03221
u463655976
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(N)]\n\nPY = sorted(PY)\n\nkeyP = -1\nfor P, Y in PY:\n if keyP != P:\n keyP = P\n keyNo = 1\n\n print("{:0>6}{:0>6}", keyP, keyNo)\n keyNo += 1\n', 'N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\n\nPY = sorted(PY)\n\nkeyP = -1\nfor P, Y in PY:\n if keyP != P:\n keyP = P\n keyNo = 1\n\n print("{:0>6}{:0>6}".format(keyP, keyNo))\n keyNo += 1\n', 'N, M = map(int, input().split())\nPY = [list(map(int, input().split() +[x])) for x in range(M)]\n\nPY = sorted(PY)\n\nkeyP = -1\nfor i, (P, Y, _) in enumerate(PY):\n if keyP != P:\n keyP = P\n keyNo = 1\n\n PY[i].append("{:0>6}{:0>6}".format(keyP, keyNo))\n keyNo += 1\n\nfor P, Y, _, s in sorted(PY, key=lambda x:x[2]):\n print(s)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s576700774', 's758525523', 's229813552']
[30092.0, 28832.0, 39348.0]
[711.0, 661.0, 824.0]
[228, 235, 327]
p03221
u463775490
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 = [[] for _ in range(n+1)]\nfor i in range(m):\n p,y = map(int,input().split())\n s[p].append([y,i])\ns[p].sort()\nans = ['']*m\nfor p in range(1,n+1):\n cnt = 1\n for (y,i) in s[p]:\n ans[i] = '{:06}{:06}'.format(p,cnt)\n cnt += 1\nprint(' '.join(ans))", "n,m = map(int,input().split())\ns = [[] for _ in range(n+1)]\nfor i in range(m):\n p,y = map(int,input().split())\n s[p].append([y,i])\nans = [0]*m\nfor p in range(1,n+1):\n cnt = 1\n for (y,i) in sorted(s[p]):\n ans[i] = '{:06}{:06}'.format(p,cnt)\n cnt += 1\nfor j in range(len(ans)):\n print(ans[j])"]
['Wrong Answer', 'Accepted']
['s388752787', 's168684615']
[41416.0, 39088.0]
[613.0, 708.0]
[301, 319]
p03221
u470208427
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()))\na = [[] for i in range(n+1)]\nb = []\nfor i in range(m):\n p,s = list(map(int,input().split()))\n a[p].append(s)\n b.append([p,s])\nprint(a)\nfor i in range(n+1):\n a[i].sort()\nprint(a)\nfor i in range(m):\n ken = b[i][0]\n si = a[ken].index(b[i][1]) +1\n ken = str(ken).zfill(6)\n si = str(si).zfill(6)\n print("".join([ken,si]))', 'n,m = list(map(int,input().split()))\na = [[None] for i in range(n+1)]\nb = [None]*m\nfor i in range(m):\n p,s = list(map(int,input().split()))\n a[p].append(s)\n b[i] = [p,s]\nprint(a)\nfor i in a:\n a[i].sort()\nprint(a)\nfor i in b:\n ken = b[i][0]\n si = a[ken].index(b[i][1]) +1\n ken = str(ken).zfill(6)\n si = str(si).zfill(6)\n print("".join([ken,si]))', 'from bisect import bisect_left\n\n\nn,m = list(map(int,input().split()))\na = [[0] for i in range(n)]\nb = [None]*m\nfor i in range(m):\n p,s = list(map(int,input().split()))\n p-=1\n a[p].append(s)\n b[i] = [p,s]\nfor i in range(len(a)):\n a[i].sort()\nfor i in range(len(b)):\n ken = b[i][0]\n si = bisect_left(a[ken], b[i][1])\n ken = str(ken+1).zfill(6)\n si = str(si).zfill(6)\n print("".join([ken,si]))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s012304314', 's134258949', 's788408954']
[41200.0, 43000.0, 38920.0]
[2105.0, 602.0, 840.0]
[380, 371, 420]
p03221
u471828790
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 heapq\nimport sys\n#input = sys.stdin.readline().strip\nN, M = map(int, input().split())\nclist = []\nHQ = [[] for _ in range(N)]\nfor i in range(M):\n p, y = map(int, input().split())\n clist.append((p, y))\n heapq.heappush(HQ[p - 1], y)\nprint(HQ)\n\ncmap = {}\nfor p, q in enumerate(HQ):\n cnt = 0\n for i in range(len(q)):\n y = heapq.heappop(q)\n cmap[str(p) + '_' + str(y)] = i + 1\n\nfor p, y in clist:\n idx = cmap[str(p - 1) + '_' + str(y)]\n print('{0:06d}'.format(p) + '{0:06d}'.format(idx))\n", "import heapq\nimport sys\n#input = sys.stdin.readline().strip\nN, M = map(int, input().split())\nclist = []\nHQ = [[] for _ in range(N)]\nfor i in range(M):\n p, y = map(int, input().split())\n clist.append((p, y))\n heapq.heappush(HQ[p - 1], y)\n\ncmap = {}\nfor p, q in enumerate(HQ):\n cnt = 0\n for i in range(len(q)):\n y = heapq.heappop(q)\n cmap[str(p) + '_' + str(y)] = i + 1\n\nfor p, y in clist:\n idx = cmap[str(p - 1) + '_' + str(y)]\n print('{0:06d}'.format(p) + '{0:06d}'.format(idx))\n"]
['Wrong Answer', 'Accepted']
['s242098242', 's536030238']
[45856.0, 43240.0]
[910.0, 841.0]
[524, 514]
p03221
u473530997
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\nclass City:\n def __init__(self, index, pref, time):\n self.index = index\n self.pref = pref\n self.time = time\n self.sort_res = None\n def get_id(self):\n str1 = "0"*(6-len(str(self.pref)))+str(self.pref)\n str2 = "0"*(6-len(str(self.sort_res)))+str(self.sort_res)\n return str1 + str2\nif __name__ == \'__main__\':\n nm = list(sys.stdin,readline().split(" "))\n N = int(nm[0])\n M = int(nm[1])\n prefs = [[]] * N\n cities = []\n for i in range(M):\n info = list(sys.stdin,readline().split(" "))\n newcity = City(i,int(info[0]),int(info[1]))\n prefs[int(info[0])].append(newcity)\n for i in range(N):\n prefs[i].sort(key = lambda x: x.time)\n \tfor j in range(len(prefs[i])):\n prefs[i][j].sort_res = j+1\n for i in prefs:\n for j in i:\n cities.append(i)\n cities.sort(key = lambda x:x.index)\n for i in cities:\n print(i.get_id())\n \n \n \n ', 'import sys\n\n\nclass City:\n def __init__(self, ind, pref, time):\n self.ind = ind\n self.pref = pref\n self.time = time\n self.sort_res = None\n\n def get_id(self):\n str1 = "0" * (6 - len(str(self.pref))) + str(self.pref)\n str2 = "0" * (6 - len(str(self.sort_res))) + str(self.sort_res)\n return str1 + str2\n def __str__(self):\n \treturn str(self.ind)\nif __name__ == \'__main__\':\n nm = list(sys.stdin.readline().split(" "))\n N = int(nm[0])\n M = int(nm[1])\n prefs = [[] for x in range(N)]\n cities = []\n for i in range(M):\n info = sys.stdin.readline().rstrip().split(" ")\n newcity = City(i, int(info[0]), int(info[1]))\n prefs[int(info[0])-1].append(newcity)\n for i in range(N):\n prefs[i].sort(key=lambda x: x.time)\n for j in range(len(prefs[i])):\n prefs[i][j].sort_res = j + 1\n for i in prefs:\n for j in i:\n cities.append(j)\n cities.sort(key=lambda y: y.ind)\n for i in cities:\n print(i.get_id())\n\n\n']
['Runtime Error', 'Accepted']
['s893229141', 's583213649']
[3064.0, 52592.0]
[18.0, 927.0]
[892, 1047]
p03221
u474270503
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)]\nPY=list(sorted(PY))\nls=[]\ncurrent=0\nct=1\nfor i in range(M):\n s1=str(PY[i][0])\n s2=''\n for j in range(6-len(s1)):\n s2+='0'\n s3=s2+s1\n\n if current==PY[i][0]:\n ct+=1\n else:\n ct=1\n current=PY[i][0]\n\n s4=str(ct)\n s5=''\n for j in range(6-len(s1)):\n s5+='0'\n s6=s5+s4\n s7=s3+s6\n\n ls.append([s7,PY[i][2]])\n\n\nfor i in ls:\n print(i[0])\n", "N,M=map(int, input().split())\nPY=[list(map(int, input().split()))+[i] for i in range(M)]\nPY=list(sorted(PY))\nls=[]\ncurrent=0\nct=1\nfor i in range(M):\n s1=str(PY[i][0])\n s2=''\n for j in range(6-len(s1)):\n s2+='0'\n s3=s2+s1\n\n if current==PY[i][0]:\n ct+=1\n else:\n ct=1\n current=PY[i][0]\n\n s4=str(ct)\n s5=''\n for j in range(6-len(s4)):\n s5+='0'\n s6=s5+s4\n s7=s3+s6\n\n ls.append([s7,PY[i][2]])\n\nls=sorted(ls, key=lambda x :x[1])\nfor i in ls:\n print(i[0])\n"]
['Wrong Answer', 'Accepted']
['s915827678', 's766429145']
[41420.0, 43880.0]
[964.0, 1090.0]
[489, 522]
p03221
u476124554
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['n,m = map(int,input().split())\np,y = [],[]\nfor i in range(m):\n v1,v2 = map(int,input().split())\n p.append(v1)\n y.append(v2)\n \npy = zip(p,y,range(m))\npy = sorted(py)\np,y,index = zip(*py)\n \nans = []\nstart = p[0]\ncount = 1\nfor i in range(m):\n if start == p[i]:\n ans.append(str(p[i]).zfill(6) + str(count).zfill(6))\n count += 1\n else:\n count = 1\n start = p[i]\n ans.append(str(p[i]).zfill(6) + str(count).zfill(6))\n count += 1\n \nans = zip(index,ans)\nans = sorted(ans1)\nindex,ans = zip(*ans)\nfor i in ans:\n print(i)', 'n,m = map(int,input().split())\np,y = [],[]\nfor i in range(m):\n v1,v2 = map(int,input().split())\n p.append(v1)\n y.append(v2)\n \npy = zip(p,y,range(m))\npy = sorted(py)\np,y,index = zip(*py)\n \nans = []\nstart = p[0]\ncount = 1\nfor i in range(m):\n if start == p[i]:\n ans.append(str(p[i]).zfill(6) + str(count).zfill(6))\n count += 1\n else:\n count = 1\n start = p[i]\n ans.append(str(p[i]).zfill(6) + str(count).zfill(6))\n count += 1\n \nans = zip(index,ans)\nans = sorted(ans)\nindex,ans = zip(*ans)\nfor i in ans:\n print(i)']
['Runtime Error', 'Accepted']
['s670554191', 's714454907']
[31484.0, 44972.0]
[620.0, 867.0]
[572, 571]
p03221
u476435125
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.
['#nm=list(map(int,input().split()))\n#n=nm[0]\n#m=nm[1]\nn,m=map(int,input().split())\n#py=[]\ny=[]\n#py=[[[]]*m]\npy=[[]]*m\n#y=[[]]*n\n#print(py)\n\n# py.append([])\nfor i in range (n):\n y.append([])\nfor i in range(m):\n py[i]=list(map(int,input().split()))\n y[py[i][0]-1].append(py[i][1])\nfor i in range(n):\n y[i].sort()\n#print(py)\n#print(y)\nd_y={}\nfor i in range(m):\n for j in range(len(y[i])):\n d_y[y[i][j]]=j+1\nfor i in range(m):\n if py[i][0]<10:\n print("00000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<100:\n print("0000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<1000:\n print("000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<10000:\n print("00"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<100000:\n print("0"+str(py[i][0]*10**6+d_y[py[i][1]]))\n else:\n print(str(py[i][0]*10**6+d_y[py[i][1]]))\n', 'n,m=map(int,input().split())\n#py=[[[]]*m]\npy=[[]]*m\ny=[[]]*n\n\n# py.append([])\n\n# y.append([])\nfor i in range(m):\n py[i]=list(map(int,input().split()))\n y[py[i][0]-1].append(py[i][1])\nfor i in range(n):\n y[i].sort()\n#print(py)\n#print(y)\nfor i in range(m):\n if py[i][0]<10:\n print("00000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<100:\n print("0000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<1000:\n print("000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<10000:\n print("00"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<100000:\n print("0"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n else:\n print(str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n', 'nm=list(map(int,input().split()))\nn=nm[0]\nm=nm[1]\npy=[]\ny=[]\nfor i in range(m):\n py.append([])\nfor i in range (n):\n y.append([])\nfor i in range(m):\n py[i]=list(map(int,input().split()))\n y[py[i][0]-1].append(py[i][1])\nfor i in range(n):\n y[i].sort()\nprint(py)\nprint(y)\nfor i in range(m):\n if py[i][0]<10:\n print("00000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<100:\n print("0000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<1000:\n print("000"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<10000:\n print("00"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n elif py[i][0]<100000:\n print("0"+str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))\n else:\n print(str(py[i][0]*10**6+y[py[i][0]-1].index(py[i][1])+1))', '#nm=list(map(int,input().split()))\n#n=nm[0]\n#m=nm[1]\nn,m=map(int,input().split())\n#py=[]\ny=[]\n#py=[[[]]*m]\npy=[[]]*m\n#y=[[]]*n\n#print(py)\n\n# py.append([])\nfor i in range (n):\n y.append([])\nfor i in range(m):\n py[i]=list(map(int,input().split()))\n y[py[i][0]-1].append(py[i][1])\nfor i in range(n):\n y[i].sort()\n#print(py)\n#print(y)\nd_y={}\nfor i in range(n):\n for j in range(len(y[i])):\n d_y[y[i][j]]=j+1\nfor i in range(m):\n if py[i][0]<10:\n print("00000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<100:\n print("0000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<1000:\n print("000"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<10000:\n print("00"+str(py[i][0]*10**6+d_y[py[i][1]]))\n elif py[i][0]<100000:\n print("0"+str(py[i][0]*10**6+d_y[py[i][1]]))\n else:\n print(str(py[i][0]*10**6+d_y[py[i][1]]))\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s010920811', 's260318539', 's890511491', 's775706958']
[47428.0, 31004.0, 44000.0, 47448.0]
[750.0, 2109.0, 2106.0, 720.0]
[994, 870, 863, 994]
p03221
u477855214
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 _ in range(M):\n py.append(list(map(int, input().split())))\nd = {}\nnow = 0\nnum = 0\nfor p, y in sorted(py):\n if now != p:\n now = p\n num = 1\n d[(p, y)] = num\n num += 1\nfor p, y in py:\n print('{0:6}{0:6}'.format(p, d[(p, y)]))", "N, M = map(int, input().split())\npy = []\nfor _ in range(M):\n py.append(list(map(int, input().split())))\nd = {}\nnow = 0\nnum = 0\nfor p, y in sorted(py):\n if now != p:\n now = p\n num = 1\n d[(p, y)] = num\n num += 1\nfor p, y in py:\n print('{0:06}{0:06}'.format(p, d[(p, y)]))", "N, M = map(int, input().split())\npy = []\nfor _ in range(M):\n py.append(list(map(int, input().split())))\nd = {}\nnow = 0\nnum = 0\nfor p, y in sorted(py):\n if now != p:\n now = p\n num = 1\n d[(p, y)] = num\n num += 1\nfor p, y in py:\n print('{:06d}{:06d}'.format(p, d[(p, y)]))"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s407557610', 's863374925', 's788732125']
[45836.0, 45832.0, 45836.0]
[762.0, 747.0, 756.0]
[296, 298, 298]
p03221
u480200603
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())\ncity = [[0] for _ in range(n)]\nbuffer = []\n\nfor i in range(m):\n p, y = map(int, input().split())\n buffer.append(list([p, y]))\n city[p - 1].append(y)\n\nfor i in range(n):\n city[i].sort()\n\nfor i in range(m):\n p, y = buffer[i]\n print(str(p).zfill(6) + str(city[p - 1].index(y)).zfill(6))\n', 'import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nl = []\nnum = 1\nans = [""] * m\n\nfor i in range(m):\n p, y = map(int, input().split())\n l.append(list([p, y, i]))\n\nl.sort()\nprint(l)\n\npn = l[0][0]\n\nfor p, y, i in l:\n if p == pn:\n ans[i] = str(p).zfill(6) + str(num).zfill(6)\n num += 1\n else:\n num = 1\n ans[i] = str(p).zfill(6) + str(num).zfill(6)\n num += 1\n\nfor a in ans:\n print(a)\n', 'import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nl = []\nnum = [0] * n\nans = [""] * m\n\nfor i in range(m):\n p, y = map(int, input().split())\n l.append(list([p, y, i]))\n\nl.sort()\n\n\nfor p, y, i in l:\n num[p - 1] += 1\n ans[i] = str(p).zfill(6) + str(num[p - 1]).zfill(6)\n\nfor a in ans:\n print(a)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s231234648', 's962313169', 's251547632']
[3064.0, 37372.0, 35220.0]
[17.0, 646.0, 549.0]
[376, 451, 329]
p03221
u485716382
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 \n \n \n\n N, M = map(int, input().split())\n # PY = []\n # for _ in range(M):\n # a = list(map(int, input().split()))\n # PY.append(a)\n PY = [list(map(int, input().split())) for _ in range(M)]\n PY_sorted = sorted(PY, key=lambda x: x[1])\n\n city_count = {}\n order = {}\n for i, (p, y) in enumerate(PY_sorted):\n if not p in city_count:\n city_count[p] = 0\n city_count[p] += 1\n order[p, i] = city_count[p]\n \n for i, (p, y) in enumerate(PY):\n print('{:06}{:06}'.format(p, order[p, i]))\n\nmain()", "def main():\n \n \n \n \n\n N, M = map(int, input().split())\n PY = []\n for _ in range(M):\n a = list(map(int, input().split()))\n PY.append(a)\n PY_sorted = sorted(PY, key=lambda x: x[1])\n\n city_count = {}\n order = {}\n for i, (p, y) in enumerate(PY_sorted):\n if not p in city_count:\n city_count[p] = 0\n city_count[p] += 1\n order[p, i] = city_count[p]\n \n for i, (p, y) in enumerate(PY):\n print('{:06}{:06}'.format(p, order[p, i]))\n\nmain()", "def main():\n \n \n \n \n\n N, M = map(int, input().split())\n iPY = []\n for i in enumerate(range(M)):\n p, y = map(int, input().split())\n iPY.append([i, p, y])\n # PY = [list(map(int, input().split())) for _ in range(M)]\n iPY_sorted = sorted(iPY, key=lambda x: x[2])\n\n city_count = {}\n order = {}\n for i, p, y in iPY_sorted:\n if not p in city_count:\n city_count[p] = 0\n city_count[p] += 1\n order[p, i] = city_count[p]\n \n for i, p, y in enumerate(iPY):\n print('{:06}{:06}'.format(p, order[p, i]))\n\nmain()", "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 \ncity_count = {}\norder = {}\n \nfor i, p, y in sorted(iPY, key=lambda x: x[2]):\n if not p in city_count:\n city_count[p] = 0\n city_count[p] += 1\n order[p, i] = city_count[p]\n \nfor i, p, y in iPY:\n print('{:06}{:06}'.format(p, order[p, i]))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s163197459', 's693509299', 's835033595', 's056954062']
[51824.0, 51828.0, 54016.0, 44484.0]
[725.0, 734.0, 616.0, 747.0]
[770, 703, 771, 385]
p03221
u493520238
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["\nn,m = map(int, input().split())\npyl = [ [] for _ in range(n+1) ]\n\nfor i in range(m):\n p,y = map(int, input().split())\n pyl[p].append((y,i))\n\nans = ['']*m\nfor p, yil in enumerate(pyl):\n top = str(p).zfill(6)\n yil.sort()\n for order,(y,i) in enumerate(yil):\n print(order,i)\n bottom = order+1\n bottom = str(bottom).zfill(6)\n ans[i] = top+bottom\n\nfor a in ans:\n print(a)", "\nn,m = map(int, input().split())\npyl = [ [] for _ in range(n+1) ]\n\nfor i in range(m):\n p,y = map(int, input().split())\n pyl[p].append((y,i))\n\nans = ['']*m\nfor p, yil in enumerate(pyl):\n top = str(p).zfill(6)\n yil.sort()\n for order,(y,i) in enumerate(yil):\n bottom = order+1\n bottom = str(bottom).zfill(6)\n ans[i] = top+bottom\n\nfor a in ans:\n print(a)"]
['Wrong Answer', 'Accepted']
['s906908562', 's961624241']
[39076.0, 39000.0]
[502.0, 448.0]
[412, 389]
p03221
u494058663
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())\nprefecture = [[] for i in range(N+1)]\nans = []\nfor i in range(M):\n p,y = map(int,input().split())\n prefecture[p].append([y,i])\n prefecture[p].sort()\nfor i in range(1,N+1):\n tmp_p = str(i)\n while(len(tmp_p)!=6):\n tmp_p = '0'+tmp_p\n for j in range(1,len(prefecture[i])+1):\n tmp_x = str(j)\n while (len(tmp_x)!=6):\n tmp_x = '0'+tmp_x\n ans.append([prefecture[i][j-1][1],tmp_p+tmp_x])\nans.sort()\nprint(prefecture)\nprint(ans)\nfor i in range(len(ans)):\n print(ans[i][1])\n ", "N,M = map(int,input().split())\nprefecture = [[] for i in range(N+1)]\nans = []\nfor i in range(M):\n p,y = map(int,input().split())\n prefecture[p].append([y,i])\n\nfor i in range(1,N+1):\n prefecture[i].sort()\n for j in range(1,len(prefecture[i])+1):\n ans.append([prefecture[i][j-1][1],i,j])\nans.sort()\nfor i in range(len(ans)):\n print('{:06}{:06}'.format(ans[i][1],ans[i][2]))\n "]
['Wrong Answer', 'Accepted']
['s737864983', 's401407691']
[58244.0, 45388.0]
[2105.0, 893.0]
[613, 452]
p03221
u496744988
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['n, m = map(int, input().split())\n\ncities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))\nprint(cities)\npref = cities[0]\ncounter = 1\nfor city in cities:\n if pref != city[0]:\n counter = 1\n pref = city[0]\n rank = counter\n number = str(pref).zfill(6) + str(rank).zfill(6)\n city.append(number)\n counter += 1\nfor i in sorted(cities, key=lambda x: x[2]):\n print(i[3])\n', 'n, m = map(int, input().split())\n\ncities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))\npref = cities[0]\ncounter = 1\nfor city in cities:\n if pref != city[0]:\n counter = 1\n pref = city[0]\n rank = counter\n number = str(pref).zfill(6) + str(rank).zfill(6)\n city.append(number)\n counter += 1\nfor i in sorted(cities, key=lambda x: x[2]):\n print(i[3])\n']
['Wrong Answer', 'Accepted']
['s458853963', 's929305486']
[39372.0, 35376.0]
[913.0, 848.0]
[431, 417]
p03221
u499966353
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 = []\nfor i in range(m):\n p, y = map(int, input().split())\n ps.append([p, y, i+1])\n\nps = sorted(ps)\nps\n\nans = []\ncount = 1\nfor i in range(m):\n if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):\n count = 1\n else:\n pass\n ans.append([(ps[i])[2], 100000*((ps[i])[0]) + count])\n count += 1\n\nans = sorted(ans)\n\nfor i in ans:\n aw = i[1]\n aww = str(aw).zfill(12)\n print(aww)', 'n, m = map(int, input().split())\nps = []\nfor i in range(m):\n p, y = map(int, input().split())\n ps.append([p, y, i+1])\n\nps = sorted(ps)\nps\n\nans = []\ncount = 1\nfor i in range(m):\n if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):\n count = 1\n else:\n pass\n ans.append([(ps[i])[2], 100000*((ps[i])[0]) + count])\n count += 1\n\nans = sorted(ans)\n\nfor i in ans:\n aw = i[1]\n aww = str(aw).zfill(12)\n print(aww)', 'n, m = map(int, input().split())\nps = []\nfor i in range(m):\n p, y = map(int, input().split())\n ps.append([p, y, i+1])\n\nps = sorted(ps)\nps\n\nans = []\ncount = 1\nfor i in range(m):\n if (i != 0 and (ps[i])[0] != (ps[i-1])[0]):\n count = 1\n else:\n pass\n ans.append([(ps[i])[2], 1000000*((ps[i])[0]) + count])\n count += 1\n\nans = sorted(ans)\n\nfor i in ans:\n aw = i[1]\n aww = str(aw).zfill(12)\n print(aww)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s848025865', 's895040222', 's710158596']
[39484.0, 39484.0, 39484.0]
[908.0, 1005.0, 889.0]
[435, 435, 436]
p03221
u500297289
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\n\nl = [[] for _ in range(N + 1)]\n\nfor py in PY:\n l[py[0]].append(py[1])\n\nfor py in PY:\n l[py[0]].sort()\n\nfor py in PY:\n print('{:0>7}'.format(py[0]) + '{:0>7}'.format(l[py[0]].index(py[1]) + 1))\n", "N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\n\nl = [[] for _ in range(N + 1)]\n\nfor py in PY:\n l[py[0]].append(py[1])\n\nfor py in PY:\n l[py[0]].sort()\n\nfor py in PY:\n print('{:0>6}'.format(py[0]), '{:0>6}'.format(l[py[0]].index(py[1]) + 1))\n", "N, M = map(int, input().split())\nPY = [list(map(int, input().split())) for _ in range(M)]\n\nl = [[] for _ in range(N + 1)]\n\nfor py in PY:\n l[py[0]].append(py[1])\n\nfor py in PY:\n l[py[0]].sort()\n\nfor py in PY:\n print('{:0>7}'.format(py[0]), '{:0>7}'.format(l[py[0]].index(py[1]) + 1))\n", "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])\n\nPY.sort()\n\nn = 1\nnow = PY[0][0]\nfor py in PY:\n if now != py[0]:\n now = py[0]\n n = 1\n py[1] = n\n n += 1\n\nPY.sort(key=lambda val: val[2])\n\nfor py in PY:\n print('{:0>6}'.format(py[0]) + '{:0>6}'.format(py[1]))\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s059861487', 's499436753', 's752934200', 's341856845']
[36148.0, 36136.0, 36368.0, 24740.0]
[2106.0, 2106.0, 2106.0, 730.0]
[293, 292, 292, 356]
p03221
u501451051
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\nlis = []\nfor i in range(m):\n a = list(map(int, input().split()))\n a.append(i)\n lis.append(a)\nprint(lis)\n\nt = 1\ntmp = sorted(lis)[0][0]\n\nnlis =[]\n\nfor i in sorted(lis):\n if tmp == i[0]:\n a = str(i[0])\n left = a.zfill(6)\n right = str(t).zfill(6)\n t += 1\n else:\n t = 1\n tmp = i[0]\n left = str(i[0]).zfill(6)\n right = str(t).zfill(6)\n \n nlis.append([i[2],left+right])\n\nfor j in sorted(nlis):\n print(j[1])\n', 'n , m = map(int, input().split())\n\nlis = []\nfor _ in range(m):\n lis.append(list(map(int, input().split())))\n\nt = 1\ntmp = sorted(lis)[0][0]\n\nfor i in sorted(lis):\n if tmp == i[0]:\n a = str(i[0])\n left = a.zfill(6)\n right = str(t).zfill(6)\n t += 1\n else:\n t = 1\n tmp = i[0]\n left = str(i[0]).zfill(6)\n right = str(t).zfill(6)\n \n print(left+right)', 'n , m = map(int, input().split())\n\nlis = []\nfor _ in range(m):\n lis.append(list(map(int, input().split())))\n\nprint(lis)\nprint(sorted(lis))\n\nt = 1\ntmp = sorted(lis)[0][0]\n\nfor i in sorted(lis):\n if tmp == i[0]:\n a = str(i[0])\n left = a.zfill(6)\n right = str(t).zfill(6)\n t += 1\n else:\n t = 1\n tmp = i[0]\n left = str(i[0]).zfill(6)\n right = str(t).zfill(6)\n \n print(left+right)', 'n , m = map(int, input().split())\n\nlis = []\nfor i in range(m):\n a = list(map(int, input().split()))\n a.append(i)\n lis.append(a)\n\nt = 1\ntmp = sorted(lis)[0][0]\n\nnlis =[]\n\nfor i in sorted(lis):\n if tmp == i[0]:\n left = str(i[0]).zfill(6)\n right = str(t).zfill(6)\n t += 1\n else:\n t = 1\n tmp = i[0]\n left = str(i[0]).zfill(6)\n right = str(t).zfill(6)\n t += 1\n \n nlis.append([i[2],left+right])\n\nfor j in sorted(nlis):\n print(j[1])\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s319381610', 's346084329', 's786448573', 's142344805']
[46928.0, 28368.0, 31772.0, 46784.0]
[801.0, 561.0, 773.0, 821.0]
[516, 415, 446, 506]
p03221
u502314533
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())\nyears = []\nfor i in range(1,M+1):\n p,y = map(int,input().split())\n years.append((p,y,i))\n\nprefectureOrdering = [1] * (10 ** 5 + 1)\ninputOrdering = [False] * (10 ** 5 + 1)\n\nyears.sort()\n\nprint(years)\nfor i in years:\n s = ""\n s += "0" * (6 - len(str(i[0]))) + str(i[0]) + "0" * (6 - len(str(prefectureOrdering[i[0]]))) + str(prefectureOrdering[i[0]])\n prefectureOrdering[i[0]] += 1\n inputOrdering[i[2]] = s\n\nfor i in range(1,M+1):\n print(inputOrdering[i])', 'N,M = map(int,input().split())\nyears = []\nfor i in range(1,M+1):\n p,y = map(int,input().split())\n years.append((p,y,i))\n\nprefectureOrdering = [1] * (10 ** 5 + 1)\ninputOrdering = [False] * (10 ** 5 + 1)\n\nyears.sort()\n\nfor i in years:\n s = ""\n s += "0" * (6 - len(str(i[0]))) + str(i[0]) + "0" * (6 - len(str(prefectureOrdering[i[0]]))) + str(prefectureOrdering[i[0]])\n prefectureOrdering[i[0]] += 1\n inputOrdering[i[2]] = s\n\nfor i in range(1,M+1):\n print(inputOrdering[i])']
['Wrong Answer', 'Accepted']
['s036382971', 's203217882']
[32668.0, 29820.0]
[720.0, 717.0]
[505, 492]
p03221
u502731482
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["\nn, m = map(int, input().split())\ndata = [[] for _ in range(n)]\nfor i in range(m):\n p, y = map(int, input().split())\n data[p - 1].append([y, i])\n\nans = [None] * m\nfor i in range(n):\n data[i].sort()\n for j in range(len(data[i])):\n y, k = data[i][j]\n print(k)\n ans[k] = '0' * (6 - len(str(i + 1))) + str(i + 1) + '0' * (6 - len(str(j + 1))) + str(j + 1)\n\nfor i in range(len(ans)):\n print(ans[i])", "\nn, m = map(int, input().split())\ndata = [[] for _ in range(n)]\nfor i in range(m):\n p, y = map(int, input().split())\n data[p - 1].append([y, i])\n\nans = [None] * m\nfor i in range(n):\n data[i].sort()\n for j in range(len(data[i])):\n y, k = data[i][j]\n ans[k] = '0' * (6 - len(str(i + 1))) + str(i + 1) + '0' * (6 - len(str(j + 1))) + str(j + 1)\n\nfor i in range(len(ans)):\n print(ans[i])"]
['Wrong Answer', 'Accepted']
['s152962655', 's554643878']
[39908.0, 39088.0]
[936.0, 895.0]
[430, 413]
p03221
u504562455
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()]\ncity = []\npref = [0 for i in range(n)]\nfor i in range(m):\n p, y = [int(_) for _ in input().split()]\n pref[p-1] += 1\n city.append([p,y,i])\n\ncity.sort(key = lambda x: (x[0], x[1]))\ncnt = 1\nfor i in range(m):\n city[i].append(cnt)\n if cnt == pref[city[i][0]-1]:\n cnt = 1\n else:\n cnt += 1\ncity.sort(key = lambda x: x[2])\nfor i in range(m):\n print(str(city[i][0]).zfill(6), str(city[i][3]).zfill(6))', 'n, m = [int(i) for i in input().split()]\ncity = []\npref = [0 for i in range(n)]\nfor i in range(m):\n p, y = [int(_) for _ in input().split()]\n pref[p-1] += 1\n city.append([p,y,i])\n\ncity.sort(key = lambda x: (x[0], x[1]))\ncnt = 1\nfor i in range(m):\n city[i].append(cnt)\n if cnt == pref[city[i][0]-1]:\n cnt = 1\n else:\n cnt += 1\ncity.sort(key = lambda x: x[2])\nfor i in range(m):\n print(str(city[i][0]).zfill(6)+str(city[i][3]).zfill(6))']
['Wrong Answer', 'Accepted']
['s226235541', 's661809135']
[36376.0, 36272.0]
[869.0, 856.0]
[469, 468]
p03221
u505420467
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=[]\nfor i in range(m):\n a,b=map(int,input().split())\n p.append([i,a,b,0])\nps=sorted(p,key=lambda i:(i[1],i[2]))\ncnt=1\nprint(ps)\nfor i in range(m):\n if i!=0:\n if ps[i][1]==ps[i-1][1]:\n print("aaa")\n cnt+=1\n ps[i][3]=cnt\n else:\n ps[i][3]=1\n cnt=1\n else:\n ps[i][3]=1\nps=sorted(ps,key=lambda i:i[0])\nprint(ps)\nfor i in range(m):\n print("{0:06d}".format(ps[i][1]),end=\'\')\n print("{0:06d}".format(ps[i][3]))\n', 'n,m=map(int,input().split())\np=[]\nfor i in range(m):\n a,b=map(int,input().split())\n p.append([i,a,b,0])\nps=sorted(p,key=lambda i:(i[1],i[2]))\ncnt=1\nfor i in range(m):\n if i!=0:\n if ps[i][1]==ps[i-1][1]:\n cnt+=1\n ps[i][3]=cnt\n else:\n ps[i][3]=1\n cnt=1\n else:\n ps[i][3]=1\nps=sorted(ps,key=lambda i:i[0])\nfor i in range(m):\n print("{0:06d}".format(ps[i][1]),end=\'\')\n print("{0:06d}".format(ps[i][3]))\n']
['Wrong Answer', 'Accepted']
['s817658557', 's024525998']
[49256.0, 35104.0]
[1123.0, 912.0]
[554, 509]
p03221
u506689504
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())\ncities = {}\nP = {}\nY = []\nfor i in range(M):\n p,y = map(int, input().split())\n cities[i] = (p,y)\n Y.append(y)\n\nsorted_Y = sorted(Y)\nsorted_P = {p:sorted(P[p].items(), key=lambda x:x[1]) for p in P}\n\nP_i = np.zeros(N)\nans = {}\nfor i in sorted_Y:\n city = Y.index(i)+1\n ans[city] = i\n\nfor i in ans:\n p,y = cities[i]\n print('{0:06}{1:06}'.format(p, i))\n", "import numpy as np\nN, M = map(int, input().split())\ncities = {}\nP = {}\nY = {}\nfor i in range(M):\n p,y = map(int, input().split())\n cities[i] = p\n Y[i] = y\n\nans = []\nsorted_Y = sorted(Y.items(), key=lambda x:x[1])\nP_i = np.zeros(N)\nfor i,y in sorted_Y:\n p = cities[i]\n P_i[p] += 1\n ans.append(p,P_i[p])\n\nfor p,x in ans:\n print('{0:06}{1:06}'.format(p, x))\n", "N, M = map(int, input().split())\nP = {}\n\nfor i in range(M):\n p,y = map(int, input().split())\n if not p in P:\n P[p] = [y]\n else:\n P[p].append(y)\n\nsorted_city = {p:sorted(P[p]) for p in P}\n\nprint(sorted_city)\nfor p, cities in sorted(sorted_city.items()):\n for i,city in enumerate(cities):\n print('{0:06d}{1:06d}'.format(p,i+1))\n", '"""\nimport numpy as np\nN, M = map(int, input().split())\ncities = {}\nY = {}\nfor i in range(M):\n p,y = map(int, input().split())\n cities[i] = p\n Y[i] = y\n\nans = {}\nsorted_Y = sorted(Y.items(), key=lambda x:x[1])\nP_i = np.zeros(N)\nfor i,y in sorted_Y:\n p = cities[i]\n P_i[p-1] += 1\n ans[i] = (p, int(P_i[p-1]))\n\nfor i in range(M):\n print(\'{0:06}{1:06}\'.format(ans[i][0], ans[i][1]))\n"""\n\nn, m = map(int,input().split())\npys = []\nfor i in range(m):\n x = map(int, input().split())\n x = [x[0],x[1],i]\n pys.append(x)\n\npys.sort()\npp = -1\nlid = 0\nans = []\nfor i in range(m):\n if pp == pys[i][0]:\n lid += 1\n else:\n lid = 1\n pp = pys[i][0]\n ans.append(pp*10**6+lid)\n\nfor v in ans:\n print(\':012d\'.format(v))\n', '"""\nimport numpy as np\nN, M = map(int, input().split())\ncities = {}\nY = {}\nfor i in range(M):\n p,y = map(int, input().split())\n cities[i] = p\n Y[i] = y\n\nans = {}\nsorted_Y = sorted(Y.items(), key=lambda x:x[1])\nP_i = np.zeros(N)\nfor i,y in sorted_Y:\n p = cities[i]\n P_i[p-1] += 1\n ans[i] = (p, int(P_i[p-1]))\n\nfor i in range(M):\n print(\'{0:06}{1:06}\'.format(ans[i][0], ans[i][1]))\n"""\n\nn, m = map(int,input().split())\npys = []\nfor i in range(m):\n x = list(map(int, input().split()))\n x = [x[0],x[1],i]\n pys.append(x)\n\npys.sort()\npp = -1\nlid = 0\nans = [0]*m\nfor i in range(m):\n if pp == pys[i][0]:\n lid += 1\n else:\n lid = 1\n pp = pys[i][0]\n ans[pys[i][2]] = pp*10**6+lid\n\nfor v in ans:\n print(\'{:012d}\'.format(v))\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s265647120', 's528936679', 's546019895', 's855092420', 's662350373']
[38276.0, 52292.0, 56024.0, 3064.0, 29376.0]
[2113.0, 769.0, 789.0, 17.0, 677.0]
[422, 376, 360, 759, 775]
p03221
u506910932
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['import bisect\nn, m = map(int, input().split())\n\n\norder = []\npre = [[0] for _ in range(n + 1)]\n\nfor i in range(m):\n p, y = map(int, input().split())\n order.append([p, y])\n pre[p].append(y)\n\n\nfor i in range(n + 1):\n pre[p].sort()\n\n順に,各県の何番目かをにぶたんで探す', "from collections import defaultdict\nn, m = map(int, input().split())\norder = []\ndd = defaultdict(int)\n\nfor i in range(m):\n p, y = map(int, input().split())\n order.append([i, p, y])\n\n\norder.sort(key=lambda x: (x[2]))\nans = []\nfor ii, pp, yy in order:\n dd[pp] += 1\n ans.append('{:0>6}{:0>6}'.format(pp, dd[pp]))\n\nprint('\\n'.join(ans))\n", "import bisect\nn, m = map(int, input().split())\n\n\norder = []\npre = [[0] for _ in range(n + 1)]\n\nfor i in range(m):\n p, y = map(int, input().split())\n order.append([p, y])\n pre[p].append(y)\n\n\nfor i in range(n + 1):\n pre[p].sort()\n\n順に,各県の何番目かをにぶたんで探す\nfor pp, year in order:\n print('{:0>6}'.format(pp) +\n '{:0>6}'.format(bisect.bisect_left(pre[pp], year)))\n", "from collections import defaultdict\nn, m = map(int, input().split())\norder = []\ndd = defaultdict(int)\n\nfor i in range(m):\n p, y = map(int, input().split())\n order.append([i, p, y])\n\n\norder.sort(key=lambda x: (x[2]))\n# print(order)\n\nans = ['']*m\nfor ii, pp, yy in order:\n dd[pp] += 1\n ans[ii] = '{:0>6}{:0>6}'.format(pp, dd[pp])\n\nprint('\\n'.join(ans))\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s026858995', 's519006432', 's988654722', 's519089528']
[35880.0, 43564.0, 35704.0, 43800.0]
[2206.0, 419.0, 2206.0, 448.0]
[343, 377, 461, 395]
p03221
u513081876
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 = [[] for i in range(M)]\nans = [""] * M\nnum = [0] * M\nfor i in range(M):\n ken, year = map(int, input().split())\n data[i] = [ken, year, i]\n \ndata.sort(key=lambda x:x[1])\n\nfor p, y, i in data:\n num[p-1] += 1\n ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)\n\nfor i in M:\n print(ans[i])', 'N, M = map(int, input().split())\ndata = [[] for i in range(M)]\nans = [""] * M\nnum = [0] * M\nfor i in range(M):\n ken, year = map(int, input().split())\n data[i] = [ken, year, i]\n \ndata.sort(key=lambda x:x[1])\n\nfor p, y, i in data:\n num[p-1] += 1\n ans[i] = (str(p).zfill(6) + str(num[p]).zfill(6))\n\nfor i in ans:\n print(i)', 'N, M = map(int, input().split())\ndata = [[] for i in range(M)]\nans = [""] * (M+1)\nnum = [0] * (M+1)\nfor i in range(M):\n ken, year = map(int, input().split())\n data[i] = [ken, year, i]\n \ndata.sort(key=lambda x:x[1])\n\nfor p, y, i in data:\n num[p-1] += 1\n ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)\n\nfor i in ans:\n print(i)', 'N, M = map(int, input().split())\ncnt = [0 for i in range(n + 1)] \ncheck = []\nans = []\n\nfor i in range(m):\n p, y = map(int, input().split())\n check.append((y, p, i))\n\ncheck.sort()\n\nfor y, p, i in check:\n cnt[p] += 1\n ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))\n\nans.sort()\n\nfor aa, bb in ans:\n print(bb)', 'N, M = map(int, input().split())\ndata = [[] for i in range(M)]\nans = [""] * M\nnum = [0] * N\nfor i in range(M):\n ken, year = map(int, input().split())\n data[i] = [ken, year, i]\n \ndata.sort(key=lambda x:x[1])\n\nfor p, y, i in data:\n num[p-1] += 1\n ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)\n\nfor i in ans:\n print(i)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s010168535', 's416736957', 's474187722', 's637665826', 's566995558']
[30896.0, 32164.0, 32176.0, 3064.0, 32160.0]
[562.0, 619.0, 663.0, 17.0, 630.0]
[340, 337, 345, 326, 337]
p03221
u513434790
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\nfrom itertools import accumulate\n\nN, M = map(int, input().split())\nP = []\np = [0] * (N+1)\nfor i in range(M):\n p1, y1 = map(str, input().split())\n p[int(p1)] += 1\n P.append(int(p1+y1.rjust(10,"0")))\n \nans = np.argsort(P)\nans = np.argsort(ans)\np = list(accumulate(p))\n\nfor i in range(M):\n a = P[i] // 10 ** 6 \n print(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0"))', 'import numpy as np\nfrom itertools import accumulate\n\nN, M = map(int, input().split())\nP = []\np = [0] * (N+1)\nfor i in range(M):\n p1, y1 = map(str, input().split())\n p[int(p1)] += 1\n P.append(int(p1+y1.rjust(6,"0")))\n \nans = np.argsort(P)\nans = np.argsort(ans)\np = list(accumulate(p))\n\nfor i in range(M):\n a = P[i] // 10 ** 6 \n print(int(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0")))', 'import numpy as np\nfrom itertools import groupby, accumulate\n\nN, M = map(int, input().split())\nP = []\nY = []\nfor i in range(M):\n p1, y1 = map(int, input().split())\n P.append(p1)\n Y.append(y1)\n \ny = np.argsort(P)\nyy = [P[i] for i in y]\nnn = [0] + [len(list(j)) for i, j in groupby(yy)]\nn = list(accumulate(nn))\ncity = [np.argsort(yy[n[i]:n[i+1]]) for i in range(len(n)-1)]\n\nk = []\nfor i in range(1,len(n)):\n for j in range(nn[i]):\n k.append(str(i).rjust(6,"0") + str(city[i-1][j]+1).rjust(6,"0"))\n \nans = [0] * M \nfor i in range(M):\n ans[y[i]] = k[i]\n \nfor i in range(M):\n print(ans[i])', 'import numpy as np\nfrom itertools import accumulate\n\nN, M = map(int, input().split())\nP = []\np = [0] * (N+1)\nfor i in range(M):\n p1, y1 = map(str, input().split())\n p[int(p1)] += 1\n P.append(int(p1+y1.rjust(10,"0")))\n \nans = np.argsort(P)\nans = np.argsort(ans)\np = list(accumulate(p))\n\nfor i in range(M):\n a = P[i] // 10 ** 10 \n print(str(a).rjust(6,"0") + str(ans[i] - p[a-1] + 1).rjust(6,"0"))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s022449731', 's060377171', 's610915692', 's382544903']
[22184.0, 22268.0, 51756.0, 22800.0]
[581.0, 567.0, 2022.0, 1453.0]
[412, 416, 622, 413]
p03221
u515052479
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 = []\nbase_1 = []\nkey = {}\nans_str = []\nans_n = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n base.append([p,y])\n base_1.append([p,y])\n \nbase_1.sort(key = lambda x:x[1])\n\nfor i in range(m):\n p_str = str(base_1[i][0])\n len_p = len(list(p_str))\n temp = "p"+p_str\n \n if temp not in key:\n key[temp] = 1\n count = str(1)\n else :\n a = key[temp]\n key[temp] = a + 1\n count = str(key[temp])\n \n len_count = len(list(count))\n \n for j in range(6-len_p):\n p_str = "0" + p_str\n \n for j in range(6-len_count):\n count = "0" + count\n \n print(p_str + count)', 'n,m = map(int,input().split())\nbase_1 = []\nkey = {}\nans_str = []\nans_n = []\n\nfor i in range(m):\n p,y = map(int,input().split())\n base_1.append([p,y,i])\n \nbase_1.sort(key = lambda x:x[1])\n\nfor i in range(m):\n p_str = str(base_1[i][0])\n len_p = len(list(p_str))\n temp = "p"+p_str\n \n if temp not in key:\n key[temp] = 1\n count = str(1)\n else :\n a = key[temp]\n key[temp] = a + 1\n count = str(key[temp])\n \n len_count = len(list(count))\n \n for j in range(6-len_p):\n p_str = "0" + p_str\n \n for j in range(6-len_count):\n count = "0" + count\n \n base_1[i].append(p_str + count)\n \nbase_1.sort(key = lambda x:x[2])\n\nfor i in range(m):\n print(base_1[i][3])']
['Wrong Answer', 'Accepted']
['s624858344', 's241282745']
[45108.0, 47152.0]
[942.0, 1013.0]
[628, 690]
p03221
u518042385
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n p,y=map(int,input().split())\n l.append([y,i,p])\nl=sorted(l)\nl1=[0 for i in range(n+1)] \nl2=[[] for i in range(m)] #shi\nfor i in range(m):\n l1[l[i][2]]+=1\n l2[l[i][1]]=[l1[l[i][2]],l[i][2]]\nfor i in range(m):\n w=""\n w+="0"*(6-len(str(l[i][1])))+str(l2[i][1])+"0"*(6-len(str(l[i][0])))+str(l2[i][0])\n print(w)', 'n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n p,y=map(int,input().split())\n l.append([y,i,p])\nl=sorted(l)\nl1=[0 for i in range(n+1)] \nl2=[[] for i in range(m)] #shi\nfor i in range(m):\n l1[l[i][2]]+=1\n l2[l[i][1]]=[l1[l[i][2]],l[i][2]]\nfor i in range(m):\n w=""\n w+="0"*(6-len(str(l2[i][1])))+str(l2[i][1])+"0"*(6-len(str(l2[i][0])))+str(l2[i][0])\n print(w)']
['Wrong Answer', 'Accepted']
['s113473077', 's260338776']
[38308.0, 39632.0]
[969.0, 900.0]
[400, 402]
p03221
u518375128
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\ndef main():\n N,M = list(map(int, input().split()))\n lst = []\n anslst = []\n for i in range(M):\n P,Y = list(map(int, input().split()))\n lst.append({'city_id':i, 'pref':P, 'year':Y})\n print(lst)\n for i in range(N):\n tmp = [ d for d in lst if d['pref'] == i+1]\n print(tmp)\n sor = sorted(tmp, key = itemgetter('year'))\n for j in range(len(sor)):\n city_id = sor[j]['city_id']\n pref = sor[j]['pref']\n year = sor[j]['year']\n id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)\n anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})\n anslst = sorted(anslst, key = itemgetter('city_id'))\n print(anslst)\n for i in range(len(anslst)):\n print(anslst[i]['id'])\n\nif __name__ == '__main__':\n main()\n", "from operator import itemgetter\n\ndef main():\n N,M = list(map(int, input().split()))\n lst = [[] for i in range(N+1)]\n anslst = []\n\n for i in range(M):\n P,Y = list(map(int, input().split()))\n lst[P].append({'city_id':i, 'pref':P, 'year':Y})\n\n for i in range(N):\n tmp = lst[i+1]\n for j in range(len(tmp)):\n city_id = tmp[j]['city_id']\n pref = tmp[j]['pref']\n year = tmp[j]['year']\n id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)\n anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})\n\n anslst = sorted(anslst, key = itemgetter('city_id'))\n for i in range(len(anslst)):\n print(anslst[i]['id'])\n\nif __name__ == '__main__':\n main()\n", "from operator import itemgetter\n\ndef main():\n N,M = list(map(int, input().split()))\n lst = [[] for i in range(N)]\n anslst = []\n\n for i in range(M):\n P,Y = list(map(int, input().split()))\n lst[P-1].append({'city_id':i, 'pref':P, 'year':Y})\n\n for i in range(N):\n tmp = lst[i]\n for j in range(len(tmp)):\n city_id = tmp[j]['city_id']\n pref = tmp[j]['pref']\n year = tmp[j]['year']\n id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)\n anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})\n\n anslst = sorted(anslst, key = itemgetter('city_id'))\n for i in range(len(anslst)):\n print(anslst[i]['id'])\n\nif __name__ == '__main__':\n main()\n", "from operator import itemgetter\n\ndef main():\n N,M = list(map(int, input().split()))\n lst = [[] for i in range(N)]\n anslst = []\n\n for i in range(M):\n P,Y = list(map(int, input().split()))\n lst[P-1].append({'city_id':i, 'pref':P, 'year':Y})\n\n for i in range(N):\n tmp = lst[i]\n tmp = sorted(tmp, key = itemgetter('year'))\n for j in range(len(tmp)):\n city_id = tmp[j]['city_id']\n pref = tmp[j]['pref']\n year = tmp[j]['year']\n id = '{0:06d}'.format(pref) + '{0:06d}'.format(j+1)\n anslst.append({'city_id':city_id, 'pref':pref, 'year':year, 'id':id})\n\n anslst = sorted(anslst, key = itemgetter('city_id'))\n for i in range(len(anslst)):\n print(anslst[i]['id'])\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s187263888', 's552540662', 's660968674', 's238814900']
[115488.0, 99560.0, 99520.0, 99504.0]
[2107.0, 898.0, 887.0, 1075.0]
[866, 761, 759, 811]
p03221
u521323621
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.
['t=input()\nN=int(t.split()[0])\nM=int(t.split()[1])\n\ncity=[0]*M\nfor i in range(M):\n te=[int(x) for x in input().split()]\n city[i]={\'i\':i+1,\'p\':int(te[0]),\'y\':int(te[1])}\n\ncity_sorted = sorted(city,key = lambda x: (x[\'p\'], x[\'y\']))\n\nx=0\ntemp_p=city_sorted[0][\'p\']\nfor c in city_sorted:\n if temp_p == c[\'p\']:\n x+=1\n else:\n print("hoge")\n temp_p=c[\'p\']\n x=1\n c[\'id\']="{0:06d}{1:06d}".format(c[\'p\'],x)\n \nfor ci in city:\n print(ci[\'id\'])\n ', 't=input()\nN=int(t.split()[0])\nM=int(t.split()[1])\n\ncity=[0]*M\nfor i in range(M):\n te=[int(x) for x in input().split()]\n city[i]={\'i\':i+1,\'p\':int(te[0]),\'y\':int(te[1])}\n\ncity_sorted = sorted(city,key = lambda x: (x[\'p\'], x[\'y\']))\n\nx=0\ntemp_p=city_sorted[0][\'p\']\nfor c in city_sorted:\n if temp_p == c[\'p\']:\n x+=1\n else:\n temp_p=c[\'p\']\n x=1\n c[\'id\']="{0:06d}{1:06d}".format(c[\'p\'],x)\n \nfor ci in city:\n print(ci[\'id\'])\n ']
['Wrong Answer', 'Accepted']
['s191464063', 's623143135']
[52304.0, 52020.0]
[810.0, 772.0]
[452, 434]
p03221
u527261492
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([p,y])\nlst.sort(lambda x:(x[0],x[1]))\nj=1\nfor i in range(m):\n if lst[i][0]==lst[min(m-1,i+1)][0]:\n s=str(lst[i][0])\n t=str(j)\n s.zfill(6)\n t.zfill(6)\n u=s+t\n j+=1\n print(int(u))\n else:\n s=str(lst[i][0])\n t=str(j)\n s.zfill(6)\n t.zfill(6)\n u=s+t\n j-=j-1\n print(int(u))\n \n \n', 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\n\nfor k in range(m):\n print(str(lst[k][0])+str(lst[k][1]))\n \n \n\n\n\n', 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([i,p,y])\nlst.sort(key=lambda x:(x[1],x[2]))\nj=1\nLst=[]\nfor i in range(m):\n if lst[i][1]==lst[min(m-1,i+1)][1]:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j+=1\n Lst.append([lst[i][0],u])\n else:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j-=j-1\n Lst.append([lst[i][0],u])\nLst.sort(lambda x:x[0])\nfor k in range(m):\n print(Lst[k][1])\n \n', "n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:x[0])\nlst.sort(key=lambda x:x[1])\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\ndef plus0(s):\n while len(s)<6:\n s='0'+s\nfor k in range(m):\n lst[k][0]=plus0(str(lst[k][0]))\n lst[k][1]=plus0(str(lst[k][1]))\n print(''.join(lst[k]))\n \n\n\n\n", "n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\ndef plus0(s):\n while len(s)<6:\n s='0'+s\nfor k in range(m):\n lst[k][0]=plus0(str(lst[k][0]))\n lst[k][1]=plus0(str(lst[k][1]))\n print(''.join(lst[k]))\n \n\n\n\n", 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([p,y])\nlst.sort(lambda x:(x[0],x[1]))\nj=1\nfor i in range(m):\n if i<m-1:\n if lst[i][0]==lst[i+1][0]:\n s=str(lst[i][0])\n t=str(j)\n s.zfill(6)\n t.zfill(6)\n u=s+t\n j+=1\n print(int(u))\n else:\n s=str(lst[i][0])\n t=str(j)\n s.zfill(6)\n t.zfill(6)\n u=s+t\n j-=j-1\n print(int(u))\n \n \n', "n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\ndef plus0(s):\n while len(s)<6:\n ''.join(list(s).insert(0,'0'))\nfor k in range(m):\n print(plus0(str(lst[k][0]))+plus0(str(lst[k][1])))\n \n \n\n\n\n", 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\n\nfor k in range(m):\n print(plus0(str(lst[k][0]))+plus0(str(lst[k][1])))\n \n \n\n\n\n', "n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\ndef plus0(s):\n while len(s)<6:\n s='0'+s\nfor k in range(m):\n print(plus0(str(lst[k][0]))+plus0(str(lst[k][1])))\n \n \n\n\n\n", "n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n P,Y=map(int,input().split())\n lst.append([P,Y])\nlst.sort(key=lambda x:(x[0],x[1]))\nlst[0][1]=1\nfor j in range(m-1):\n if lst[j][0]==lst[j+1][0]:\n lst[j+1][1]=lst[j][1]+1\n else:\n lst[j+1][1]=1\ndef plus0(s):\n while len(s)<6:\n s.insert(0,'0')\nfor k in range(m):\n lst[k][0]=plus0(str(lst[k][0]))\n lst[k][1]=plus0(str(lst[k][1]))\n print(''.join(lst[k]))\n \n\n\n\n", 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([p,y])\nlst.sort(lambda x:(x[0],x[1]))\nfor i in range(m):\n j=1\n while lst[i][0]==lst[min(m-1,i+1)][0]:\n s=str(lst[i][0])\n t=str(j)\n s.zfill(6)\n t.zfill(6)\n u=s+t\n j+=1\n print(int(u))\n \n ', 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([i,p,y])\nlst.sort(lambda x:(x[1],x[2]))\nj=1\nLst=[]\nfor i in range(m):\n if lst[i][1]==lst[min(m-1,i+1)][1]:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j+=1\n Lst.append([lst[i][0],u])\n else:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j-=j-1\n Lst.append([lst[i][0],u])\nLst.sort(lambda x:x[0])\nfor k in range(m):\n print(Lst[k][1])\n \n', 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([p,y])\nlst.sort(lambda x:(x[0],x[1]))\nj=1\nfor i in range(m):\n if lst[i][0]==lst[min(m-1,i+1)][0]:\n s=str(lst[i][0])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j+=1\n print(int(u))\n else:\n s=str(lst[i][0])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j-=j-1\n print(int(u))\n \n \n', 'n,m=map(int,input().split())\nlst=[]\nfor i in range(m):\n p,y=map(int,input().split())\n lst.append([i,p,y])\nlst.sort(key=lambda x:(x[1],x[2]))\nj=1\nLst=[]\nfor i in range(m):\n if lst[i][1]==lst[min(m-1,i+1)][1]:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j+=1\n Lst.append([lst[i][0],u])\n else:\n s=str(lst[i][1])\n t=str(j)\n u=s.zfill(6)+t.zfill(6)\n j-=j-1\n Lst.append([lst[i][0],u])\nLst.sort(key=lambda x:x[0])\nfor k in range(m):\n print(Lst[k][1])\n \n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s314427640', 's344649725', 's444767814', 's490666095', 's544383447', 's556533226', 's621586971', 's689541952', 's772874994', 's795147145', 's867135013', 's875273773', 's877887486', 's432733405']
[19628.0, 28480.0, 39840.0, 21268.0, 27656.0, 19620.0, 27652.0, 27644.0, 27652.0, 27632.0, 19616.0, 22792.0, 19616.0, 41376.0]
[334.0, 631.0, 744.0, 553.0, 559.0, 336.0, 521.0, 505.0, 553.0, 545.0, 330.0, 345.0, 332.0, 955.0]
[418, 325, 488, 440, 419, 453, 405, 339, 382, 427, 311, 484, 394, 492]
p03221
u529012223
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\n\nN, M = map(int, input().split())\nP = [list(map(int, input().split())) for i in range(M)]\n\nans = collections.defaultdict(list)\n\nfor p, y in sorted(P):\n ans[p] += [y]\nfor p, y in P:\n print("%06d%06d"%(p, bisect.bisect(a[p], y)))', 'import collections\nimport bisect\n\nN, M = map(int, input().split())\nP = [list(map(int, input().split())) for i in range(M)]\n\nans = collections.defaultdict(list)\n\nfor p, y in sorted(P):\n ans[p] += [y]\nfor p, y in P:\n print("%06d%06d"%(p, bisect.bisect(ans[p], y)))']
['Runtime Error', 'Accepted']
['s458983157', 's681438050']
[43324.0, 43324.0]
[541.0, 765.0]
[266, 268]
p03221
u530110933
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
['# -*- coding: utf-8 -*-\n\nimport sys\nimport itertools\nimport math\n\nN,M=[int(x) for x in input().split()]\nC=[[int(x) for x in input().split()] for i in range(M)]\n\nps=dict()\nfor c,(p,y) in enumerate(C):\n if not p in ps:\n ps[p]=[]\n ps[p].append((y,c))\n\nqs=[]\nfor p,cs in ps.items():\n cs.sort()\n qs += [(c,p,i) for i,(y,c) in enumerate(cs)]\n\nqs.sort()\n\nfor c,p,i in qs:\n print("{0:0=6}{1:0=6}".format(p,i))\n\n\n', '# -*- coding: utf-8 -*-\n\nimport sys\nimport itertools\nimport math\n\nN,M=[int(x) for x in input().split()]\nC=[[int(x) for x in input().split()] for i in range(M)]\n\nps=dict()\nfor c,(p,y) in enumerate(C):\n if not p in ps:\n ps[p]=[]\n ps[p].append((y,c))\n\nqs=[]\nfor p,cs in ps.items():\n cs.sort()\n qs += [(c,p,i) for i,(y,c) in enumerate(cs)]\n\nqs.sort()\n\nfor c,p,i in qs:\n print("{0:0=6}{1:0=6}".format(p,i))\n\n\n', '# -*- coding: utf-8 -*-\n\nimport sys\nimport itertools\nimport math\n\nN,M=[int(x) for x in input().split()]\nC=[[int(x) for x in input().split()] for i in range(M)]\n\nps=dict()\nfor c,(p,y) in enumerate(C):\n if not p in ps:\n ps[p]=[]\n ps[p].append((y,c))\n\nqs=[]\nfor p,cs in ps.items():\n cs.sort()\n qs += [(c,p,i) for i,(y,c) in enumerate(cs)]\n\nqs.sort()\n\nfor c,p,i in qs:\n print("{0:0=6}{1:0=6}".format(p,i+1))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s000359030', 's405951692', 's541507806']
[57792.0, 57792.0, 57792.0]
[833.0, 776.0, 818.0]
[426, 426, 426]
p03221
u535907456
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["from bisect import bisect\nL = list(map(int,input().split()))\nN = L[0]\nM = L[1]\nP = list()\nY = list()\nS = list()\nfor x in range(0,N):\n S.append(list())\nfor x in range(0,M):\n X = list(map(int,input().split()))\n P.append(X[0])\n Y.append(X[1])\n S[X[0]-1].append(X[1])\nfor y in range(0,M):\n n = 0\n n = bisect(S[P[y]-1],Y[y])\n nstr = str(n)\n Pstr = str(P[y])\n while len(nstr) < 6:\n nstr = '0' + nstr\n while len(Pstr) < 6:\n Pstr = '0' + Pstr\n number = Pstr + nstr\n print(number)", "L = list(map(int,input().split()))\nN = L[0]\nM = L[1]\nPY = list()\n\nfor x in range(0,M):\n X = list(map(int,input().split()))\n PY.append((X[0],X[1],x))\n\nsortedPY = sorted(PY, key=lambda x:x[1])\nID = [0 for i in range(N)]\n\nfor y in range(0,M):\n n = sortedPY[y][0]\n n = n-1\n ID[n] = ID[n] + 1\n nstr = str(ID[n])\n Pstr = str(sortedPY[y][0])\n while len(nstr) < 6:\n nstr = '0' + nstr\n while len(Pstr) < 6:\n Pstr = '0' + Pstr\n PY[sortedPY[y][2]] = Pstr + nstr\n number = Pstr + nstr\n\nfor x in range(0,M):\n print(PY[x])"]
['Wrong Answer', 'Accepted']
['s320239432', 's225133384']
[30224.0, 30416.0]
[777.0, 864.0]
[524, 558]
p03221
u538381753
2,000
1,048,576
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities.
["from collections import defaultdict\n\nn, m = [int(x) for x in input().split(' ')]\npy = [tuple(input().split(' ')) for _ in range(m)]\n\nd = defaultdict(list)\n\nfor x, y in py:\n d[x].append(int(y))\n\nans = {}\n\nfor k, v in d.items():\n print(k, v)\n for i, x in enumerate(sorted(v), start=1):\n ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)\n\nfor x in py:\n print(ans[x])\n", "from collections import defaultdict\n\nn, m = [int(x) for x in input().split(' ')]\npy = sorted(\n sorted(\n [input().split(' ') + [i] for i, _ in enumerate(range(m))],\n key=lambda x: int(x[1])\n ),\n key=lambda x: x[2]\n )\n\nd = defaultdict(int)\n\nfor p, _, _ in py:\n d[p] += 1\n print(p.zfill(6) + str(d[p]).zfill(6))\n", "from collections import defaultdict\n \nn, m = [int(x) for x in input().split(' ')]\npy = [tuple(input().split(' ')) for _ in range(m)]\n \nd = defaultdict(list)\n \nfor x, y in py:\n d[x].append(int(y))\n \nans = {}\n \nfor k, v in d.items():\n for i, x in enumerate(sorted(v), start=1):\n ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)\n \nfor x in py:\n print(ans[x])"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s477506126', 's977346071', 's022344669']
[73108.0, 40476.0, 71508.0]
[983.0, 587.0, 751.0]
[381, 361, 370]
p03221
u540761833
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.append([p,y,i])\nPY.sort()\nprint(PY)\n\nans = [0 for i in range(M)]\nc = 1\nd = 0\nfor i in range(M):\n \n if c == PY[i][0]:\n d += 1\n else:\n c = PY[i][0]\n d = 1\n ans[PY[i][2]] = '0'*(6-len(str(PY[i][0]))) + str(PY[i][0]) + '0'*(6-len(str(PY[i][1]))) + str(d)\nfor i in ans:\n print(i)", "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()\n\n\nans = [0 for i in range(M)]\nc = 1\nd = 0\nfor i in range(M):\n \n if c == PY[i][0]:\n d += 1\n else:\n c = PY[i][0]\n d = 1\n ans[PY[i][2]] = '0'*(6-len(str(PY[i][0]))) + str(PY[i][0]) + '0'*(6-len(str(PY[i][1]))) + str(d)\nfor i in ans:\n print(i)", "N,M = map(int,input().split())\narray=[]\nfor i in range(M):\n P,Y = list(map(int,input().split()))\n array.append([P,Y])\narray2 = sorted(array)\narraysorted1 = []\nj = 1\nk = 0\nwhile j != N+1:\n array3=[]\n while k <= M-1:\n if array2[k][0] == j:\n array3.append(array2[k][1])\n k += 1\n array3= sorted(array3)\n arraysorted1.append(array3)\n k = len(arraysorted1[j-1])\n j += 1\nfor n in range(M):\n for m in range(len(arraysorted1[array[n][0]-1])):\n if array[n] == [array[n][0], arraysorted1[array[n][0]-1][m]]:\n lenf = 6-len(str(array[n][0]))\n lenl = 6-len(str(array[n][1]))\n \n print('0'*lenf +str(array[n][0])+'0'*lenl + str(m+1))\n", "N,M = map(int,input().split())\nPYi = []\npmin = float('inf')\nfor i in range(M):\n p,y = map(int,input().split())\n PYi.append([p,y,i])\n pmin = min(pmin,p)\nPYi.sort()\nnow = pmin\ncount = 1\nfor i in range(M):\n p,y,j = PYi[i]\n if now == p:\n PYi[i][1] = count\n count += 1\n else:\n now = p\n PYi[i][1] = 1\n count = 2\nPYi.sort(key = lambda x:x[2])\nfor p,y,i in PYi:\n p = str(p)\n y = str(y)\n print('0'*(6-len(p)) + p + '0'*(6-len(y)) + y)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s028823786', 's190602736', 's747335921', 's346934469']
[33932.0, 31444.0, 21336.0, 24700.0]
[781.0, 764.0, 2105.0, 792.0]
[411, 402, 721, 487]
p03221
u540815635
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 zeroPadding(num):\n return "%06d"%num\n\nclass Row:\n def __init__(self, i, pref_id, year):\n self.i = i\n self.pref_id = pref_id\n self.year = year\n self.city_id = -1\n \n def __str__(self):\n return "{i: %d, pref_id: %d, year: %d, city_id: %d}"%(self.i, self.pref_id, self.year, self.city_id)\n \n def set_city_id(self, city_id):\n self.city_id = city_id\n \n def get_sort_key(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.year ) \n \n def get_str(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.city_id)\n\nN, M = map(int,input().split()) \n\nrow_list = []\n\nfor i in range(M):\n d = list(map(int,input().split())) \n row_list.append(Row(i, d[0], d[1]))\n\nrow_list = sorted(row_list, key=lambda x: x.get_sort_key())\n\nnow_pref_id = -1a\ncnt = 1\n\nresult = []\nfor i, row in enumerate(row_list):\n if row.pref_id != now_pref_id:\n now_pref_id = row.pref_id\n cnt = 1\n \n row.set_city_id(cnt)\n row_list[i] = row\n cnt += 1\n\n[print(x.get_str()) for x in sorted(row_list, key=lambda x: x.i)]', 'N, M = map(int,input().split()) \n\nrow_list = []\n\nfor i in range(M):\n d = list(map(int,input().split())) \n row_list.append(Row(i, d[0], d[1]))\n\ndef zeroPadding(num):\n return "%06d"%num\n\nclass Row:\n def __init__(self, i, pref_id, year):\n self.i = i\n self.pref_id = pref_id\n self.year = year\n self.city_id = -1\n \n def __str__(self):\n return "{i: %d, pref_id: %d, year: %d, city_id: %d}"%(self.i, self.pref_id, self.year, self.city_id)\n \n def set_city_id(self, city_id):\n self.city_id = city_id\n \n def get_sort_key(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.year ) \n \n def get_str(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.city_id)\n\nrow_list = sorted(row_list, key=lambda x: x.get_sort_key())\n\nnow_pref_id = -1\ncnt = 1\n\nresult = []\nfor i, row in enumerate(row_list):\n if row.pref_id != now_pref_id:\n now_pref_id = row.pref_id\n cnt = 1\n \n row.set_city_id(cnt)\n row_list[i] = row\n cnt += 1\n\n[print(x.get_str()) for x in sorted(row_list, key=lambda x: x.i)]', 'N, M = map(int,input().split()) \n\nrow_list = []\n\nfor i in range(M):\n d = list(map(int,input().split())) \n row_list.append(Row(i, d[0], d[1]))\n\ndef zeroPadding(num):\n return "%06d"%num\n\nclass Row:\n def __init__(self, i, pref_id, year):\n self.i = i\n self.pref_id = pref_id\n self.year = year\n self.city_id = -1\n \n def __str__(self):\n return "{i: %d, pref_id: %d, year: %d, city_id: %d}"%(self.i, self.pref_id, self.year, self.city_id)\n \n def set_city_id(self, city_id):\n self.city_id = city_id\n \n def get_sort_key(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.year ) \n \n def get_str(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.city_id)\n\nrow_list = sorted(row_list, key=lambda x: x.get_sort_key())\n\nnow_pref_id = -1\ncnt = 1\n\nresult = []\nfor i, row in enumerate(sorted_row_list):\n if row.pref_id != now_pref_id:\n now_pref_id = row.pref_id\n cnt = 1\n \n row.set_city_id(cnt)\n sorted_row_list[i] = row\n cnt += 1\n\n[print(x.get_str()) for x in sorted(sorted_row_list, key=lambda x: x.i)]', 'N, M = map(int,input().split()) \nP = [list(map(int,input().split())) for i in range(M)]\n\ndef zeroPadding(num):\n return "%06d"%num\n\nclass Row:\n def __init__(self, i, pref_id, year):\n self.i = i\n self.pref_id = pref_id\n self.year = year\n self.city_id = -1\n \n def __str__(self):\n return "{i: %d, pref_id: %d, year: %d, city_id: %d}"%(self.i, self.pref_id, self.year, self.city_id)\n \n def set_city_id(self, city_id):\n self.city_id = city_id\n \n def get_sort_key(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.year ) \n \n def get_str(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.city_id)\n\nrow_list = [Row(i, d[0], d[1]) for i,d in enumerate(P)]\ndel P\nrow_list = sorted(row_list, key=lambda x: x.get_sort_key())\n\nnow_pref_id = -1\ncnt = 1\n\nresult = []\nfor i, row in enumerate(sorted_row_list):\n if row.pref_id != now_pref_id:\n now_pref_id = row.pref_id\n cnt = 1\n \n row.set_city_id(cnt)\n sorted_row_list[i] = row\n cnt += 1\n\n[print(x.get_str()) for x in sorted(sorted_row_list, key=lambda x: x.i)]', 'def zeroPadding(num):\n return "%06d"%num\n\ndef zeroPadding10(num):\n return "%010d"%num\n\nclass Row:\n def __init__(self, i, pref_id, year):\n self.i = i\n self.pref_id = pref_id\n self.year = year\n self.city_id = -1\n \n def __str__(self):\n return "{i: %d, pref_id: %d, year: %d, city_id: %d}"%(self.i, self.pref_id, self.year, self.city_id)\n \n def set_city_id(self, city_id):\n self.city_id = city_id\n \n def get_sort_key(self):\n return zeroPadding(self.pref_id ) + zeroPadding10(self.year) \n \n def get_str(self):\n return zeroPadding(self.pref_id ) + zeroPadding(self.city_id)\n\nN, M = map(int,input().split()) \n\nrow_list = []\n\nfor i in range(M):\n d = list(map(int,input().split())) \n row_list.append(Row(i, d[0], d[1]))\n\nrow_list = sorted(row_list, key=lambda x: x.get_sort_key())\n\nnow_pref_id = -1\ncnt = 1\n\nresult = []\nfor i, row in enumerate(row_list):\n if row.pref_id != now_pref_id:\n now_pref_id = row.pref_id\n cnt = 1\n \n row.set_city_id(cnt)\n row_list[i] = row\n cnt += 1\n\n[print(x.get_str()) for x in sorted(row_list, key=lambda x: x.i)]']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s205489945', 's259817505', 's549445128', 's884078275', 's772785067']
[3064.0, 3064.0, 3064.0, 57324.0, 50252.0]
[17.0, 17.0, 17.0, 649.0, 1029.0]
[1133, 1132, 1153, 1155, 1181]
p03221
u543954314
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 = [tuple(map(int,input().split())) for _ in range(m)]\nd = [list() for _ in range(n)]\nfor x in l:\n d[x[0]-1].append(x[1])\nfor r in d:\n r.sort()\nfor x in l:\n p = x[0]\n y = d[x[0]-1].index(x[1]) + 1\n print("{:06}{:06}".format(p,y)', 'n,m = map(int,input().split())\nl = [tuple(map(int,input().split())) for _ in range(m)]\nd = [list() for _ in range(n)]\ndic = [dict() for _ in range(n)]\nfor x in l:\n d[x[0]-1].append(x[1])\nfor r in range(n):\n d[r].sort()\n dic[r] = dict(zip(d[r],range(1,len(d[r])+1)))\nfor x in l:\n p = x[0]\n y = dic[x[0]-1][x[1]]\n print("{:06}{:06}".format(p,y))']
['Runtime Error', 'Accepted']
['s207866144', 's039562925']
[3064.0, 67104.0]
[17.0, 809.0]
[265, 349]