{"user_id": "u645250356", "problem_id": "p03038", "language": "python", "submission_id_v0": "s890208193", "submission_id_v1": "s797826633", "cpu_time_v0": 490, "cpu_time_v1": 431, "memory_v0": 71452, "memory_v1": 34916, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 12.04, "input": "from collections import Counter,defaultdict,deque\n\nfrom heapq import heapify,heappop,heappush\n\nfrom bisect import bisect_left,bisect_right\n\nimport sys,math,itertools,string,queue\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef inpl_str(): return list(sys.stdin.readline().split())\n\ndef inpln(n): return list(int(sys.stdin.readline()) for i in range(n))\n\n\n\nn,m = inpl()\n\na = inpl()\n\nb = [0] * m\n\nfor i in range(m):\n\n x,y = inpl()\n\n b[i] = [x,y]\n\na.sort()\n\nb.sort(key=lambda x:x[1], reverse = True)\n\nres = sum(a)\n\ni = 0\n\nj = 0\n\nwhile True:\n\n # print(i,j)\n\n if a[i] < b[j][1]:\n\n res += b[j][1] - a[i]\n\n i += 1\n\n else:\n\n break\n\n b[j][0] -= 1\n\n if b[j][0] == 0:\n\n j += 1\n\n if i >= n or j >= m:\n\n break\n\nprint(res)\n", "target": "from collections import Counter,defaultdict,deque\n\nfrom heapq import heappop,heappush,heapify\n\nfrom bisect import bisect_left,bisect_right \n\nimport sys,math,itertools,math,pprint\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\nINF = float('inf')\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\n\n\nn,m = inpl()\n\na = inpl()\n\na.sort()\n\nbc = [inpl() for _ in range(m)]\n\nbc.sort(key = lambda x:x[1], reverse = True)\n\nlm = sum(x[1] for x in bc)\n\nnow = 0\n\nalt = 0\n\nwhile now < n and alt < m:\n\n c,b = bc[alt]\n\n if a[now] > b:\n\n break\n\n else:\n\n a[now] = b\n\n bc[alt][0] -= 1\n\n if bc[alt][0] == 0:\n\n alt += 1\n\n now += 1\n\nprint((sum(a)))\n", "code_v0_loc": 35, "code_v1_loc": 29, "code_v0_num_chars": 880, "code_v1_num_chars": 728, "code_v0_no_empty_lines": "from collections import Counter, defaultdict, deque\nfrom heapq import heapify, heappop, heappush\nfrom bisect import bisect_left, bisect_right\nimport sys, math, itertools, string, queue\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef inpl_str():\n return list(sys.stdin.readline().split())\n\n\ndef inpln(n):\n return list(int(sys.stdin.readline()) for i in range(n))\n\n\nn, m = inpl()\na = inpl()\nb = [0] * m\nfor i in range(m):\n x, y = inpl()\n b[i] = [x, y]\na.sort()\nb.sort(key=lambda x: x[1], reverse=True)\nres = sum(a)\ni = 0\nj = 0\nwhile True:\n # print(i,j)\n if a[i] < b[j][1]:\n res += b[j][1] - a[i]\n i += 1\n else:\n break\n b[j][0] -= 1\n if b[j][0] == 0:\n j += 1\n if i >= n or j >= m:\n break\nprint(res)\n", "code_v1_no_empty_lines": "from collections import Counter, defaultdict, deque\nfrom heapq import heappop, heappush, heapify\nfrom bisect import bisect_left, bisect_right\nimport sys, math, itertools, math, pprint\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\nINF = float(\"inf\")\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\nn, m = inpl()\na = inpl()\na.sort()\nbc = [inpl() for _ in range(m)]\nbc.sort(key=lambda x: x[1], reverse=True)\nlm = sum(x[1] for x in bc)\nnow = 0\nalt = 0\nwhile now < n and alt < m:\n c, b = bc[alt]\n if a[now] > b:\n break\n else:\n a[now] = b\n bc[alt][0] -= 1\n if bc[alt][0] == 0:\n alt += 1\n now += 1\nprint((sum(a)))\n", "code_same": false, "relative_loc_diff_percent": 17.1428571429, "diff": ["-from heapq import heapify, heappop, heappush", "+from heapq import heappop, heappush, heapify", "-import sys, math, itertools, string, queue", "+import sys, math, itertools, math, pprint", "+INF = float(\"inf\")", "-def inpl_str():", "- return list(sys.stdin.readline().split())", "-", "-", "-def inpln(n):", "- return list(int(sys.stdin.readline()) for i in range(n))", "-", "-", "-b = [0] * m", "-for i in range(m):", "- x, y = inpl()", "- b[i] = [x, y]", "-b.sort(key=lambda x: x[1], reverse=True)", "-res = sum(a)", "-i = 0", "-j = 0", "-while True:", "- # print(i,j)", "- if a[i] < b[j][1]:", "- res += b[j][1] - a[i]", "- i += 1", "+bc = [inpl() for _ in range(m)]", "+bc.sort(key=lambda x: x[1], reverse=True)", "+lm = sum(x[1] for x in bc)", "+now = 0", "+alt = 0", "+while now < n and alt < m:", "+ c, b = bc[alt]", "+ if a[now] > b:", "+ break", "- break", "- b[j][0] -= 1", "- if b[j][0] == 0:", "- j += 1", "- if i >= n or j >= m:", "- break", "-print(res)", "+ a[now] = b", "+ bc[alt][0] -= 1", "+ if bc[alt][0] == 0:", "+ alt += 1", "+ now += 1", "+print((sum(a)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.310756367, "measured_runtime_v1": 0.2053928638, "runtime_lift": 1.5129852191, "key": ["s890208193", "s797826633"]} {"user_id": "u287132915", "problem_id": "p02891", "language": "python", "submission_id_v0": "s480399361", "submission_id_v1": "s640908939", "cpu_time_v0": 182, "cpu_time_v1": 72, "memory_v0": 38256, "memory_v1": 61768, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 60.44, "input": "s = input()\n\nk = int(input())\n\n\n\nif len(set(s)) == 1:\n\n print(((len(s)*k)//2))\n\n exit()\n\n\n\nss = s + s\n\n\n\nshoko = 0\n\nprev = ''\n\ncnt = 0\n\nfor i in range(len(s)):\n\n if s[i] == prev:\n\n cnt += 1\n\n else:\n\n shoko += cnt // 2\n\n cnt = 1\n\n prev = s[i]\n\nshoko += cnt // 2\n\n\n\nkosa = 0\n\nprev = ''\n\ncnt = 0\n\nfor i in range(len(ss)):\n\n if ss[i] == prev:\n\n cnt += 1\n\n else:\n\n kosa += cnt // 2\n\n cnt = 1\n\n prev = ss[i]\n\nkosa += cnt // 2\n\nkosa -= shoko\n\n\n\nprint((shoko + (k-1)*kosa))", "target": "s = input()\n\nk = int(input())\n\nn = len(s)\n\n\n\nif len(set(s)) == 1:\n\n print((n*k//2))\n\n exit()\n\n\n\nss = s + s\n\ncnts = 0\n\nnow = s[0]\n\ntemp = 1\n\nfor i in range(1, n):\n\n if s[i] == now:\n\n temp += 1\n\n else:\n\n cnts += temp // 2\n\n temp = 1\n\n now = s[i]\n\ncnts += temp // 2\n\n\n\ncntss = 0\n\nnow = ss[0]\n\ntemp = 1\n\nfor i in range(1, 2*n):\n\n if ss[i] == now:\n\n temp += 1\n\n else:\n\n cntss += temp // 2\n\n temp = 1\n\n now = ss[i]\n\ncntss += temp // 2\n\n\n\nkousa = cntss - cnts\n\nprint((cnts + kousa*(k-1)))", "code_v0_loc": 35, "code_v1_loc": 35, "code_v0_num_chars": 527, "code_v1_num_chars": 551, "code_v0_no_empty_lines": "s = input()\nk = int(input())\nif len(set(s)) == 1:\n print(((len(s) * k) // 2))\n exit()\nss = s + s\nshoko = 0\nprev = \"\"\ncnt = 0\nfor i in range(len(s)):\n if s[i] == prev:\n cnt += 1\n else:\n shoko += cnt // 2\n cnt = 1\n prev = s[i]\nshoko += cnt // 2\nkosa = 0\nprev = \"\"\ncnt = 0\nfor i in range(len(ss)):\n if ss[i] == prev:\n cnt += 1\n else:\n kosa += cnt // 2\n cnt = 1\n prev = ss[i]\nkosa += cnt // 2\nkosa -= shoko\nprint((shoko + (k - 1) * kosa))\n", "code_v1_no_empty_lines": "s = input()\nk = int(input())\nn = len(s)\nif len(set(s)) == 1:\n print((n * k // 2))\n exit()\nss = s + s\ncnts = 0\nnow = s[0]\ntemp = 1\nfor i in range(1, n):\n if s[i] == now:\n temp += 1\n else:\n cnts += temp // 2\n temp = 1\n now = s[i]\ncnts += temp // 2\ncntss = 0\nnow = ss[0]\ntemp = 1\nfor i in range(1, 2 * n):\n if ss[i] == now:\n temp += 1\n else:\n cntss += temp // 2\n temp = 1\n now = ss[i]\ncntss += temp // 2\nkousa = cntss - cnts\nprint((cnts + kousa * (k - 1)))\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["+n = len(s)", "- print(((len(s) * k) // 2))", "+ print((n * k // 2))", "-shoko = 0", "-prev = \"\"", "-cnt = 0", "-for i in range(len(s)):", "- if s[i] == prev:", "- cnt += 1", "+cnts = 0", "+now = s[0]", "+temp = 1", "+for i in range(1, n):", "+ if s[i] == now:", "+ temp += 1", "- shoko += cnt // 2", "- cnt = 1", "- prev = s[i]", "-shoko += cnt // 2", "-kosa = 0", "-prev = \"\"", "-cnt = 0", "-for i in range(len(ss)):", "- if ss[i] == prev:", "- cnt += 1", "+ cnts += temp // 2", "+ temp = 1", "+ now = s[i]", "+cnts += temp // 2", "+cntss = 0", "+now = ss[0]", "+temp = 1", "+for i in range(1, 2 * n):", "+ if ss[i] == now:", "+ temp += 1", "- kosa += cnt // 2", "- cnt = 1", "- prev = ss[i]", "-kosa += cnt // 2", "-kosa -= shoko", "-print((shoko + (k - 1) * kosa))", "+ cntss += temp // 2", "+ temp = 1", "+ now = ss[i]", "+cntss += temp // 2", "+kousa = cntss - cnts", "+print((cnts + kousa * (k - 1)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2980948234, "measured_runtime_v1": 0.2282131991, "runtime_lift": 1.3062120179, "key": ["s480399361", "s640908939"]} {"user_id": "u057109575", "problem_id": "p02814", "language": "python", "submission_id_v0": "s505874222", "submission_id_v1": "s539286615", "cpu_time_v0": 444, "cpu_time_v1": 182, "memory_v0": 96824, "memory_v1": 96876, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 59.01, "input": "from functools import reduce\n\nfrom math import gcd\n\n\n\nN, M, *A = list(map(int, open(0).read().split()))\n\n\n\ndef lcm(x, y):\n\n return x * y // gcd(x, y)\n\n\n\ndef sub_by_2(n):\n\n cnt = 0\n\n while n % 2 == 0:\n\n n //= 2\n\n cnt += 1\n\n return cnt\n\n\n\nlcm_2 = [sub_by_2(n // 2) for n in A]\n\nif all(lcm_2[0] == v for v in lcm_2):\n\n num = reduce(lcm, [v // 2 for v in A])\n\n res = M // num\n\n print((res // 2 + res % 2))\n\nelse:\n\n print((0))\n", "target": "from math import gcd\n\nfrom functools import reduce\n\n\n\nN, M, *A = list(map(int, open(0).read().split()))\n\n\n\ndef lcm(x, y):\n\n return x * y // gcd(x, y)\n\n\n\ndef lcm_list(numbers):\n\n return reduce(lcm, numbers, 1)\n\n\n\ndef even_count(n):\n\n res = 0\n\n while n % 2 == 0:\n\n res += 1\n\n n //= 2\n\n return res\n\n\n\n\n\nx = [v // 2 for v in A]\n\nif all(even_count(v) == even_count(x[0]) for v in x):\n\n num = lcm_list(x)\n\n print((-(-(M // num) // 2)))\n\nelse:\n\n print((0))\n\n\n", "code_v0_loc": 22, "code_v1_loc": 26, "code_v0_num_chars": 455, "code_v1_num_chars": 480, "code_v0_no_empty_lines": "from functools import reduce\nfrom math import gcd\n\nN, M, *A = list(map(int, open(0).read().split()))\n\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n\n\ndef sub_by_2(n):\n cnt = 0\n while n % 2 == 0:\n n //= 2\n cnt += 1\n return cnt\n\n\nlcm_2 = [sub_by_2(n // 2) for n in A]\nif all(lcm_2[0] == v for v in lcm_2):\n num = reduce(lcm, [v // 2 for v in A])\n res = M // num\n print((res // 2 + res % 2))\nelse:\n print((0))\n", "code_v1_no_empty_lines": "from math import gcd\nfrom functools import reduce\n\nN, M, *A = list(map(int, open(0).read().split()))\n\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef even_count(n):\n res = 0\n while n % 2 == 0:\n res += 1\n n //= 2\n return res\n\n\nx = [v // 2 for v in A]\nif all(even_count(v) == even_count(x[0]) for v in x):\n num = lcm_list(x)\n print((-(-(M // num) // 2)))\nelse:\n print((0))\n", "code_same": false, "relative_loc_diff_percent": 15.3846153846, "diff": ["+from math import gcd", "-from math import gcd", "-def sub_by_2(n):", "- cnt = 0", "- while n % 2 == 0:", "- n //= 2", "- cnt += 1", "- return cnt", "+def lcm_list(numbers):", "+ return reduce(lcm, numbers, 1)", "-lcm_2 = [sub_by_2(n // 2) for n in A]", "-if all(lcm_2[0] == v for v in lcm_2):", "- num = reduce(lcm, [v // 2 for v in A])", "- res = M // num", "- print((res // 2 + res % 2))", "+def even_count(n):", "+ res = 0", "+ while n % 2 == 0:", "+ res += 1", "+ n //= 2", "+ return res", "+", "+", "+x = [v // 2 for v in A]", "+if all(even_count(v) == even_count(x[0]) for v in x):", "+ num = lcm_list(x)", "+ print((-(-(M // num) // 2)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4227621694, "measured_runtime_v1": 0.2989870732, "runtime_lift": 1.4139814302, "key": ["s505874222", "s539286615"]} {"user_id": "u075012704", "problem_id": "p03558", "language": "python", "submission_id_v0": "s239051528", "submission_id_v1": "s690298448", "cpu_time_v0": 622, "cpu_time_v1": 294, "memory_v0": 102192, "memory_v1": 35324, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 52.73, "input": "from collections import deque\n\nK = int(input())\n\nG = [[] for i in range(K)]\n\n\n\nfor n in range(K):\n\n G[n].append([(n + 1) % K, 1])\n\n G[n].append([(10 * n) % K, 0])\n\n\n\nque = deque([[1, 1]])\n\ndist = [float('inf')] * K\n\n\n\nwhile que:\n\n node, cost = que.pop()\n\n dist[node] = min(cost, dist[node])\n\n for e, e_cost in G[node]:\n\n if dist[e] != float('inf'):\n\n continue\n\n\n\n if e_cost == 0:\n\n que.append([e, cost + 0])\n\n\n\n if e_cost == 1:\n\n que.appendleft([e, cost + 1])\n\n\n\nprint((dist[0]))\n", "target": "from collections import deque\n\nK = int(input())\n\nG = [[] for i in range(K)]\n\nfor i in range(K):\n\n G[i].append(((10 * i) % K, 0))\n\n G[i].append(((i + 1) % K, 1))\n\n\n\ndist = [float('inf')] * K\n\ndist[1] = 1\n\nque = deque()\n\nque.append(1)\n\n\n\nwhile que:\n\n n = que.pop()\n\n for v, c in G[n]:\n\n if dist[v] > dist[n] + c:\n\n dist[v] = dist[n] + c\n\n if c == 0:\n\n que.append(v)\n\n else:\n\n que.appendleft(v)\n\n\n\nprint((dist[0]))\n", "code_v0_loc": 25, "code_v1_loc": 23, "code_v0_num_chars": 547, "code_v1_num_chars": 492, "code_v0_no_empty_lines": "from collections import deque\n\nK = int(input())\nG = [[] for i in range(K)]\nfor n in range(K):\n G[n].append([(n + 1) % K, 1])\n G[n].append([(10 * n) % K, 0])\nque = deque([[1, 1]])\ndist = [float(\"inf\")] * K\nwhile que:\n node, cost = que.pop()\n dist[node] = min(cost, dist[node])\n for e, e_cost in G[node]:\n if dist[e] != float(\"inf\"):\n continue\n if e_cost == 0:\n que.append([e, cost + 0])\n if e_cost == 1:\n que.appendleft([e, cost + 1])\nprint((dist[0]))\n", "code_v1_no_empty_lines": "from collections import deque\n\nK = int(input())\nG = [[] for i in range(K)]\nfor i in range(K):\n G[i].append(((10 * i) % K, 0))\n G[i].append(((i + 1) % K, 1))\ndist = [float(\"inf\")] * K\ndist[1] = 1\nque = deque()\nque.append(1)\nwhile que:\n n = que.pop()\n for v, c in G[n]:\n if dist[v] > dist[n] + c:\n dist[v] = dist[n] + c\n if c == 0:\n que.append(v)\n else:\n que.appendleft(v)\nprint((dist[0]))\n", "code_same": false, "relative_loc_diff_percent": 8.0, "diff": ["-for n in range(K):", "- G[n].append([(n + 1) % K, 1])", "- G[n].append([(10 * n) % K, 0])", "-que = deque([[1, 1]])", "+for i in range(K):", "+ G[i].append(((10 * i) % K, 0))", "+ G[i].append(((i + 1) % K, 1))", "+dist[1] = 1", "+que = deque()", "+que.append(1)", "- node, cost = que.pop()", "- dist[node] = min(cost, dist[node])", "- for e, e_cost in G[node]:", "- if dist[e] != float(\"inf\"):", "- continue", "- if e_cost == 0:", "- que.append([e, cost + 0])", "- if e_cost == 1:", "- que.appendleft([e, cost + 1])", "+ n = que.pop()", "+ for v, c in G[n]:", "+ if dist[v] > dist[n] + c:", "+ dist[v] = dist[n] + c", "+ if c == 0:", "+ que.append(v)", "+ else:", "+ que.appendleft(v)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.7363213913, "measured_runtime_v1": 0.4714232118, "runtime_lift": 1.5619116176, "key": ["s239051528", "s690298448"]} {"user_id": "u633068244", "problem_id": "p01438", "language": "python", "submission_id_v0": "s057521298", "submission_id_v1": "s672157071", "cpu_time_v0": 350, "cpu_time_v1": 160, "memory_v0": 16636, "memory_v1": 11468, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 54.29, "input": "from collections import defaultdict\n\nwhile 1:\n\n n = int(input())\n\n if n == 0: break\n\n L = [0]*n\n\n D = [0]*n\n\n for man in range(n):\n\n m,l = list(map(int,input().split()))\n\n L[man] = l\n\n t = 0\n\n for date in range(m):\n\n s,e = list(map(int,input().split()))\n\n for s in range(s-6,e-6):\n\n t |= 1 << s\n\n D[man] = t\n\n\n\n dp = [defaultdict(int) for i in range(n)]\n\n dp[0][D[0]] = L[0]\n\n for i in range(1,n):\n\n for bit in list(dp[i-1].keys()):\n\n if bit&D[i] == 0:\n\n dp[i][bit|D[i]] = max(dp[i][bit|D[i]], dp[i-1][bit]+L[i])\n\n dp[i][bit] = max(dp[i][bit],dp[i-1][bit])\n\n dp[i][D[i]] = max(dp[i][D[i]], L[i])\n\n \n\n ans = max(max(dp[i].values()) for i in range(n))\n\n print(ans)", "target": "from collections import defaultdict\n\nwhile 1:\n\n n = int(input())\n\n if n == 0: break\n\n L = [0]*n\n\n T = [0]*n\n\n for man in range(n):\n\n m,l = list(map(int,input().split()))\n\n L[man] = l\n\n t = 0\n\n for date in range(m):\n\n s,e = list(map(int,input().split()))\n\n t |= 2**(e-6)-2**(s-6)\n\n T[man] = t\n\n\n\n dp = defaultdict(int)\n\n dp[T[0]] = L[0]\n\n for i in range(1,n):\n\n for bit in list(dp.keys()):\n\n if bit&T[i] == 0:\n\n dp[bit|T[i]] = max(dp[bit|T[i]], dp[bit]+L[i])\n\n dp[T[i]] = max(dp[T[i]], L[i])\n\n \n\n print(max(dp.values()))", "code_v0_loc": 27, "code_v1_loc": 24, "code_v0_num_chars": 821, "code_v1_num_chars": 646, "code_v0_no_empty_lines": "from collections import defaultdict\n\nwhile 1:\n n = int(input())\n if n == 0:\n break\n L = [0] * n\n D = [0] * n\n for man in range(n):\n m, l = list(map(int, input().split()))\n L[man] = l\n t = 0\n for date in range(m):\n s, e = list(map(int, input().split()))\n for s in range(s - 6, e - 6):\n t |= 1 << s\n D[man] = t\n dp = [defaultdict(int) for i in range(n)]\n dp[0][D[0]] = L[0]\n for i in range(1, n):\n for bit in list(dp[i - 1].keys()):\n if bit & D[i] == 0:\n dp[i][bit | D[i]] = max(dp[i][bit | D[i]], dp[i - 1][bit] + L[i])\n dp[i][bit] = max(dp[i][bit], dp[i - 1][bit])\n dp[i][D[i]] = max(dp[i][D[i]], L[i])\n ans = max(max(dp[i].values()) for i in range(n))\n print(ans)\n", "code_v1_no_empty_lines": "from collections import defaultdict\n\nwhile 1:\n n = int(input())\n if n == 0:\n break\n L = [0] * n\n T = [0] * n\n for man in range(n):\n m, l = list(map(int, input().split()))\n L[man] = l\n t = 0\n for date in range(m):\n s, e = list(map(int, input().split()))\n t |= 2 ** (e - 6) - 2 ** (s - 6)\n T[man] = t\n dp = defaultdict(int)\n dp[T[0]] = L[0]\n for i in range(1, n):\n for bit in list(dp.keys()):\n if bit & T[i] == 0:\n dp[bit | T[i]] = max(dp[bit | T[i]], dp[bit] + L[i])\n dp[T[i]] = max(dp[T[i]], L[i])\n print(max(dp.values()))\n", "code_same": false, "relative_loc_diff_percent": 11.1111111111, "diff": ["- D = [0] * n", "+ T = [0] * n", "- for s in range(s - 6, e - 6):", "- t |= 1 << s", "- D[man] = t", "- dp = [defaultdict(int) for i in range(n)]", "- dp[0][D[0]] = L[0]", "+ t |= 2 ** (e - 6) - 2 ** (s - 6)", "+ T[man] = t", "+ dp = defaultdict(int)", "+ dp[T[0]] = L[0]", "- for bit in list(dp[i - 1].keys()):", "- if bit & D[i] == 0:", "- dp[i][bit | D[i]] = max(dp[i][bit | D[i]], dp[i - 1][bit] + L[i])", "- dp[i][bit] = max(dp[i][bit], dp[i - 1][bit])", "- dp[i][D[i]] = max(dp[i][D[i]], L[i])", "- ans = max(max(dp[i].values()) for i in range(n))", "- print(ans)", "+ for bit in list(dp.keys()):", "+ if bit & T[i] == 0:", "+ dp[bit | T[i]] = max(dp[bit | T[i]], dp[bit] + L[i])", "+ dp[T[i]] = max(dp[T[i]], L[i])", "+ print(max(dp.values()))"], "diff_only_import_comment": false, "measured_runtime_v0": 1.0352676418, "measured_runtime_v1": 0.6319530358, "runtime_lift": 1.6382034472, "key": ["s057521298", "s672157071"]} {"user_id": "u380524497", "problem_id": "p03032", "language": "python", "submission_id_v0": "s669893633", "submission_id_v1": "s465849215", "cpu_time_v0": 57, "cpu_time_v1": 34, "memory_v0": 3316, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 40.35, "input": "from collections import deque\n\n\n\nn, k = list(map(int, input().split()))\n\nV = list(map(int, input().split()))\n\n\n\nans = 0\n\nfor t in range(k//2 + 1):\n\n hand = deque(V[:k-t])\n\n rest = deque(V[k-t:])\n\n cur_sum = sum(hand)\n\n\n\n for j in range(k-t+1):\n\n put_back = 0\n\n rev_hand = sorted(hand)\n\n\n\n for i in range(t):\n\n jewel = rev_hand[i]\n\n if jewel < 0:\n\n put_back -= jewel\n\n else:\n\n break\n\n\n\n candidate = cur_sum + put_back\n\n ans = max(candidate, ans)\n\n\n\n to_rest = hand.pop()\n\n rest.appendleft(to_rest)\n\n to_hand = rest.pop()\n\n hand.appendleft(to_hand)\n\n\n\n cur_sum += to_hand - to_rest\n\n\n\nprint(ans)", "target": "n, k = list(map(int, input().split()))\n\nV = list(map(int, input().split()))\n\n\n\n\n\ndef get_jewelries(box, left_pop, right_pop):\n\n if left_pop + right_pop >= len(box):\n\n return box[:]\n\n\n\n left = box[:left_pop]\n\n right = box[-right_pop:] if right_pop else []\n\n\n\n return left + right\n\n\n\n\n\ncandidates = []\n\npop_max = min(k, n)\n\nfor pop_count in range(pop_max+1):\n\n residue = k - pop_count\n\n\n\n for left_pop in range(pop_count+1):\n\n right_pop = pop_count - left_pop\n\n jewelries = get_jewelries(V, left_pop, right_pop)\n\n jewelries.sort(reverse=True)\n\n\n\n for _ in range(residue):\n\n if not jewelries:\n\n break\n\n if jewelries[-1] < 0:\n\n jewelries.pop()\n\n\n\n value = sum(jewelries)\n\n candidates.append(value)\n\n\n\nprint((max(candidates)))\n", "code_v0_loc": 33, "code_v1_loc": 34, "code_v0_num_chars": 732, "code_v1_num_chars": 833, "code_v0_no_empty_lines": "from collections import deque\n\nn, k = list(map(int, input().split()))\nV = list(map(int, input().split()))\nans = 0\nfor t in range(k // 2 + 1):\n hand = deque(V[: k - t])\n rest = deque(V[k - t :])\n cur_sum = sum(hand)\n for j in range(k - t + 1):\n put_back = 0\n rev_hand = sorted(hand)\n for i in range(t):\n jewel = rev_hand[i]\n if jewel < 0:\n put_back -= jewel\n else:\n break\n candidate = cur_sum + put_back\n ans = max(candidate, ans)\n to_rest = hand.pop()\n rest.appendleft(to_rest)\n to_hand = rest.pop()\n hand.appendleft(to_hand)\n cur_sum += to_hand - to_rest\nprint(ans)\n", "code_v1_no_empty_lines": "n, k = list(map(int, input().split()))\nV = list(map(int, input().split()))\n\n\ndef get_jewelries(box, left_pop, right_pop):\n if left_pop + right_pop >= len(box):\n return box[:]\n left = box[:left_pop]\n right = box[-right_pop:] if right_pop else []\n return left + right\n\n\ncandidates = []\npop_max = min(k, n)\nfor pop_count in range(pop_max + 1):\n residue = k - pop_count\n for left_pop in range(pop_count + 1):\n right_pop = pop_count - left_pop\n jewelries = get_jewelries(V, left_pop, right_pop)\n jewelries.sort(reverse=True)\n for _ in range(residue):\n if not jewelries:\n break\n if jewelries[-1] < 0:\n jewelries.pop()\n value = sum(jewelries)\n candidates.append(value)\nprint((max(candidates)))\n", "code_same": false, "relative_loc_diff_percent": 2.9411764706, "diff": ["-from collections import deque", "-", "-ans = 0", "-for t in range(k // 2 + 1):", "- hand = deque(V[: k - t])", "- rest = deque(V[k - t :])", "- cur_sum = sum(hand)", "- for j in range(k - t + 1):", "- put_back = 0", "- rev_hand = sorted(hand)", "- for i in range(t):", "- jewel = rev_hand[i]", "- if jewel < 0:", "- put_back -= jewel", "- else:", "+", "+", "+def get_jewelries(box, left_pop, right_pop):", "+ if left_pop + right_pop >= len(box):", "+ return box[:]", "+ left = box[:left_pop]", "+ right = box[-right_pop:] if right_pop else []", "+ return left + right", "+", "+", "+candidates = []", "+pop_max = min(k, n)", "+for pop_count in range(pop_max + 1):", "+ residue = k - pop_count", "+ for left_pop in range(pop_count + 1):", "+ right_pop = pop_count - left_pop", "+ jewelries = get_jewelries(V, left_pop, right_pop)", "+ jewelries.sort(reverse=True)", "+ for _ in range(residue):", "+ if not jewelries:", "- candidate = cur_sum + put_back", "- ans = max(candidate, ans)", "- to_rest = hand.pop()", "- rest.appendleft(to_rest)", "- to_hand = rest.pop()", "- hand.appendleft(to_hand)", "- cur_sum += to_hand - to_rest", "-print(ans)", "+ if jewelries[-1] < 0:", "+ jewelries.pop()", "+ value = sum(jewelries)", "+ candidates.append(value)", "+print((max(candidates)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2830656636, "measured_runtime_v1": 0.1950679789, "runtime_lift": 1.4511129157, "key": ["s669893633", "s465849215"]} {"user_id": "u227082700", "problem_id": "p02863", "language": "python", "submission_id_v0": "s340691380", "submission_id_v1": "s390961057", "cpu_time_v0": 541, "cpu_time_v1": 362, "memory_v0": 216520, "memory_v1": 217248, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 33.09, "input": "n,t=list(map(int,input().split()))\n\nab=[list(map(int,input().split()))for _ in range(n)]\n\nab.sort()\n\ndp=[(6007)*[0]for _ in range(n+1)]\n\ndp[0][0]=0\n\nans=0\n\nfor i in range(n):\n\n for j in range(6007):\n\n dp[i+1][j]=max(dp[i+1][j],dp[i][j])\n\n if j= A[j]:\n\n nokori -= A[j]\n\n A[j] = 0\n\n else:\n\n A[j] -= nokori\n\n nokori = 0\n\nafter = sum(A)\n\n\n\nprint((before - after))", "target": "N = int(input())\n\nA = [int(i) for i in input().split()]\n\nB = [int(i) for i in input().split()]\n\n\n\ncnt = 0\n\nfor i in range(N):\n\n if B[i] >= A[i]:\n\n cnt += A[i]\n\n B[i] -= A[i]\n\n else:\n\n cnt += B[i]\n\n B[i] = 0\n\n if B[i] == 0:\n\n continue\n\n if B[i] >= A[i+1]:\n\n cnt += A[i+1]\n\n A[i+1] = 0\n\n else:\n\n cnt += B[i]\n\n A[i+1] -= B[i]\n\n\n\nprint(cnt)", "code_v0_loc": 21, "code_v1_loc": 22, "code_v0_num_chars": 440, "code_v1_num_chars": 414, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nN = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nbefore = sum(A)\nfor i in range(N):\n nokori = B[i]\n for j in range(i, i + 2):\n if nokori >= A[j]:\n nokori -= A[j]\n A[j] = 0\n else:\n A[j] -= nokori\n nokori = 0\nafter = sum(A)\nprint((before - after))\n", "code_v1_no_empty_lines": "N = int(input())\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\ncnt = 0\nfor i in range(N):\n if B[i] >= A[i]:\n cnt += A[i]\n B[i] -= A[i]\n else:\n cnt += B[i]\n B[i] = 0\n if B[i] == 0:\n continue\n if B[i] >= A[i + 1]:\n cnt += A[i + 1]\n A[i + 1] = 0\n else:\n cnt += B[i]\n A[i + 1] -= B[i]\nprint(cnt)\n", "code_same": false, "relative_loc_diff_percent": 4.5454545455, "diff": ["-import sys", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-before = sum(A)", "+cnt = 0", "- nokori = B[i]", "- for j in range(i, i + 2):", "- if nokori >= A[j]:", "- nokori -= A[j]", "- A[j] = 0", "- else:", "- A[j] -= nokori", "- nokori = 0", "-after = sum(A)", "-print((before - after))", "+ if B[i] >= A[i]:", "+ cnt += A[i]", "+ B[i] -= A[i]", "+ else:", "+ cnt += B[i]", "+ B[i] = 0", "+ if B[i] == 0:", "+ continue", "+ if B[i] >= A[i + 1]:", "+ cnt += A[i + 1]", "+ A[i + 1] = 0", "+ else:", "+ cnt += B[i]", "+ A[i + 1] -= B[i]", "+print(cnt)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3369382279, "measured_runtime_v1": 0.0062937415, "runtime_lift": 53.5354413986, "key": ["s872669573", "s116182226"]} {"user_id": "u185948224", "problem_id": "p02873", "language": "python", "submission_id_v0": "s874712614", "submission_id_v1": "s975354355", "cpu_time_v0": 481, "cpu_time_v1": 429, "memory_v0": 27676, "memory_v1": 27548, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 10.81, "input": "S = input()\n\n\n\nlst = [1 if S[0]=='<' else -1]\n\nfor i in range(1, len(S)):\n\n if S[i] == S[i - 1]:\n\n lst[-1] += 1 if S[i]=='<' else -1\n\n else:\n\n lst.append(-1 if S[i]=='>' else 1)\n\n \n\nans = [0]\n\n\n\nfor i in range(len(lst)):\n\n if lst[i] > 0:\n\n ans += list(range(1,lst[i]+1))\n\n else:\n\n ans[-1] = max(ans[-1], -lst[i])\n\n ans += list(range(-lst[i]-1,-1, -1))\n\n\n\nprint((sum(ans)))\n", "target": "S = input()\n\n\n\nlst = [1 if S[0]=='<' else -1]\n\nfor i in range(1, len(S)):\n\n if S[i] == S[i - 1]:\n\n lst[-1] += 1 if S[i]=='<' else -1\n\n else:\n\n lst.append(-1 if S[i]=='>' else 1)\n\n \n\nans = [0]\n\n\n\nfor i in lst:\n\n if i > 0:\n\n ans += list(range(1,i+1))\n\n else:\n\n ans[-1] = max(ans[-1], -i)\n\n ans += list(range(-i-1,-1, -1))\n\n\n\n\n\nprint((sum(ans)))", "code_v0_loc": 19, "code_v1_loc": 20, "code_v0_num_chars": 425, "code_v1_num_chars": 394, "code_v0_no_empty_lines": "S = input()\nlst = [1 if S[0] == \"<\" else -1]\nfor i in range(1, len(S)):\n if S[i] == S[i - 1]:\n lst[-1] += 1 if S[i] == \"<\" else -1\n else:\n lst.append(-1 if S[i] == \">\" else 1)\nans = [0]\nfor i in range(len(lst)):\n if lst[i] > 0:\n ans += list(range(1, lst[i] + 1))\n else:\n ans[-1] = max(ans[-1], -lst[i])\n ans += list(range(-lst[i] - 1, -1, -1))\nprint((sum(ans)))\n", "code_v1_no_empty_lines": "S = input()\nlst = [1 if S[0] == \"<\" else -1]\nfor i in range(1, len(S)):\n if S[i] == S[i - 1]:\n lst[-1] += 1 if S[i] == \"<\" else -1\n else:\n lst.append(-1 if S[i] == \">\" else 1)\nans = [0]\nfor i in lst:\n if i > 0:\n ans += list(range(1, i + 1))\n else:\n ans[-1] = max(ans[-1], -i)\n ans += list(range(-i - 1, -1, -1))\nprint((sum(ans)))\n", "code_same": false, "relative_loc_diff_percent": 5.0, "diff": ["-for i in range(len(lst)):", "- if lst[i] > 0:", "- ans += list(range(1, lst[i] + 1))", "+for i in lst:", "+ if i > 0:", "+ ans += list(range(1, i + 1))", "- ans[-1] = max(ans[-1], -lst[i])", "- ans += list(range(-lst[i] - 1, -1, -1))", "+ ans[-1] = max(ans[-1], -i)", "+ ans += list(range(-i - 1, -1, -1))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2820563465, "measured_runtime_v1": 0.2050767321, "runtime_lift": 1.3753698122, "key": ["s874712614", "s975354355"]} {"user_id": "u231095456", "problem_id": "p03253", "language": "python", "submission_id_v0": "s968664754", "submission_id_v1": "s390670273", "cpu_time_v0": 89, "cpu_time_v1": 32, "memory_v0": 11252, "memory_v1": 9336, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 64.04, "input": "from math import floor, sqrt\n\nfrom collections import defaultdict\n\ndef factors(n):\n\n d = defaultdict(int)\n\n for i in range(2,floor(sqrt(n))+1):\n\n while n % i == 0:\n\n n //= i\n\n d[i] += 1\n\n if n == 1:\n\n break\n\n if n != 1:\n\n d[n] += 1\n\n return d\n\ndef inv(x, mod):\n\n k = mod - 2\n\n ret = 1\n\n while k > 0:\n\n if k&1:\n\n ret = (ret*x) % mod\n\n x = (x*x) % mod\n\n k >>= 1\n\n return ret\n\nN, M = list(map(int,input().split()))\n\nmod = 10**9+7\n\ndic = factors(M)\n\nK = len(dic)\n\nSIZE = N+max(dic.values()) if list(dic.values()) else N\n\nfact = [None]*(SIZE+1)\n\nfinv = [None]*(SIZE+1)\n\nfact[0] = 1\n\nfor i in range(1,SIZE+1):\n\n fact[i] = (fact[i-1]*i) % mod\n\nfinv[SIZE] = inv(fact[SIZE], mod=mod)\n\nfor i in range(SIZE, 0, -1):\n\n finv[i-1] = (finv[i]*i) % mod\n\ndef comb(n,k):\n\n tmp = (finv[k]*finv[n-k]) % mod\n\n return (fact[n]*tmp) % mod\n\nans = 1\n\nfor p in dic:\n\n ans = (ans*comb(dic[p]+N-1, dic[p])) % mod\n\nprint(ans)", "target": "from math import floor, sqrt\n\nfrom collections import defaultdict\n\nN,M = list(map(int,input().split()))\n\nd = defaultdict(int)\n\nfor i in range(2, floor(sqrt(M))+1):\n\n while M % i == 0:\n\n d[i] += 1\n\n M //= i\n\nif M != 1:\n\n d[M] += 1\n\ndef comb(n,k):\n\n if k == 0:\n\n return 1\n\n return comb(n-1,k-1) * n // k\n\nans = 1\n\nfor e in list(d.values()):\n\n ans *= comb(N+e-1, e)\n\nprint((ans % (10**9+7)))", "code_v0_loc": 42, "code_v1_loc": 18, "code_v0_num_chars": 1009, "code_v1_num_chars": 410, "code_v0_no_empty_lines": "from math import floor, sqrt\nfrom collections import defaultdict\n\n\ndef factors(n):\n d = defaultdict(int)\n for i in range(2, floor(sqrt(n)) + 1):\n while n % i == 0:\n n //= i\n d[i] += 1\n if n == 1:\n break\n if n != 1:\n d[n] += 1\n return d\n\n\ndef inv(x, mod):\n k = mod - 2\n ret = 1\n while k > 0:\n if k & 1:\n ret = (ret * x) % mod\n x = (x * x) % mod\n k >>= 1\n return ret\n\n\nN, M = list(map(int, input().split()))\nmod = 10**9 + 7\ndic = factors(M)\nK = len(dic)\nSIZE = N + max(dic.values()) if list(dic.values()) else N\nfact = [None] * (SIZE + 1)\nfinv = [None] * (SIZE + 1)\nfact[0] = 1\nfor i in range(1, SIZE + 1):\n fact[i] = (fact[i - 1] * i) % mod\nfinv[SIZE] = inv(fact[SIZE], mod=mod)\nfor i in range(SIZE, 0, -1):\n finv[i - 1] = (finv[i] * i) % mod\n\n\ndef comb(n, k):\n tmp = (finv[k] * finv[n - k]) % mod\n return (fact[n] * tmp) % mod\n\n\nans = 1\nfor p in dic:\n ans = (ans * comb(dic[p] + N - 1, dic[p])) % mod\nprint(ans)\n", "code_v1_no_empty_lines": "from math import floor, sqrt\nfrom collections import defaultdict\n\nN, M = list(map(int, input().split()))\nd = defaultdict(int)\nfor i in range(2, floor(sqrt(M)) + 1):\n while M % i == 0:\n d[i] += 1\n M //= i\nif M != 1:\n d[M] += 1\n\n\ndef comb(n, k):\n if k == 0:\n return 1\n return comb(n - 1, k - 1) * n // k\n\n\nans = 1\nfor e in list(d.values()):\n ans *= comb(N + e - 1, e)\nprint((ans % (10**9 + 7)))\n", "code_same": false, "relative_loc_diff_percent": 57.1428571429, "diff": ["-", "-def factors(n):", "- d = defaultdict(int)", "- for i in range(2, floor(sqrt(n)) + 1):", "- while n % i == 0:", "- n //= i", "- d[i] += 1", "- if n == 1:", "- break", "- if n != 1:", "- d[n] += 1", "- return d", "-", "-", "-def inv(x, mod):", "- k = mod - 2", "- ret = 1", "- while k > 0:", "- if k & 1:", "- ret = (ret * x) % mod", "- x = (x * x) % mod", "- k >>= 1", "- return ret", "-", "-", "-mod = 10**9 + 7", "-dic = factors(M)", "-K = len(dic)", "-SIZE = N + max(dic.values()) if list(dic.values()) else N", "-fact = [None] * (SIZE + 1)", "-finv = [None] * (SIZE + 1)", "-fact[0] = 1", "-for i in range(1, SIZE + 1):", "- fact[i] = (fact[i - 1] * i) % mod", "-finv[SIZE] = inv(fact[SIZE], mod=mod)", "-for i in range(SIZE, 0, -1):", "- finv[i - 1] = (finv[i] * i) % mod", "+d = defaultdict(int)", "+for i in range(2, floor(sqrt(M)) + 1):", "+ while M % i == 0:", "+ d[i] += 1", "+ M //= i", "+if M != 1:", "+ d[M] += 1", "- tmp = (finv[k] * finv[n - k]) % mod", "- return (fact[n] * tmp) % mod", "+ if k == 0:", "+ return 1", "+ return comb(n - 1, k - 1) * n // k", "-for p in dic:", "- ans = (ans * comb(dic[p] + N - 1, dic[p])) % mod", "-print(ans)", "+for e in list(d.values()):", "+ ans *= comb(N + e - 1, e)", "+print((ans % (10**9 + 7)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3098533685, "measured_runtime_v1": 0.2185445104, "runtime_lift": 1.4178044005, "key": ["s968664754", "s390670273"]} {"user_id": "u631277801", "problem_id": "p04020", "language": "python", "submission_id_v0": "s879592559", "submission_id_v1": "s107006666", "cpu_time_v0": 164, "cpu_time_v1": 99, "memory_v0": 19100, "memory_v1": 7072, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 39.63, "input": "import sys\n\nstdin = sys.stdin\n\n \n\nsys.setrecursionlimit(10**8) \n\n \n\ndef li(): return list(map(int, stdin.readline().split()))\n\ndef li_(): return [int(x)-1 for x in stdin.readline().split()]\n\ndef lf(): return list(map(float, stdin.readline().split()))\n\ndef ls(): return stdin.readline().split()\n\ndef ns(): return stdin.readline().rstrip()\n\ndef lc(): return list(ns())\n\ndef ni(): return int(stdin.readline())\n\ndef nf(): return float(stdin.readline())\n\n\n\n\n\nn = ni()\n\na = [ni() for _ in range(n)]\n\n\n\ncnt = {i+1: ai for i, ai in enumerate(a)}\n\n\n\nprev = -100\n\ncur = 0\n\nans = 0\n\nfor key in sorted(cnt.keys()):\n\n if cnt[key] == 0:\n\n continue\n\n \n\n if prev == -100:\n\n prev = key\n\n \n\n if (key-prev) < 2:\n\n cur += cnt[key]\n\n else:\n\n cur = cnt[key]\n\n \n\n ans += cur // 2\n\n cur -= 2 * (cur//2)\n\n \n\n prev = key\n\n \n\nprint(ans)", "target": "import sys\n\nstdin = sys.stdin\n\n\n\nsys.setrecursionlimit(10 ** 7)\n\n\n\ndef li(): return list(map(int, stdin.readline().split()))\n\ndef li_(): return [int(x) - 1 for x in stdin.readline().split()]\n\ndef lf(): return list(map(float, stdin.readline().split()))\n\ndef ls(): return stdin.readline().split()\n\ndef ns(): return stdin.readline().rstrip()\n\ndef lc(): return list(ns())\n\ndef ni(): return int(stdin.readline())\n\ndef nf(): return float(stdin.readline())\n\n\n\nn = ni()\n\n\n\nans = 0\n\nplus = 0\n\na = [ni() for _ in range(n)]\n\n\n\nfor ai in a:\n\n ans += ((ai+plus) // 2)\n\n plus = (ai+plus) % 2 if ai > 0 else 0\n\n\n\nprint(ans)", "code_v0_loc": 41, "code_v1_loc": 25, "code_v0_num_chars": 874, "code_v1_num_chars": 607, "code_v0_no_empty_lines": "import sys\n\nstdin = sys.stdin\nsys.setrecursionlimit(10**8)\n\n\ndef li():\n return list(map(int, stdin.readline().split()))\n\n\ndef li_():\n return [int(x) - 1 for x in stdin.readline().split()]\n\n\ndef lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef ls():\n return stdin.readline().split()\n\n\ndef ns():\n return stdin.readline().rstrip()\n\n\ndef lc():\n return list(ns())\n\n\ndef ni():\n return int(stdin.readline())\n\n\ndef nf():\n return float(stdin.readline())\n\n\nn = ni()\na = [ni() for _ in range(n)]\ncnt = {i + 1: ai for i, ai in enumerate(a)}\nprev = -100\ncur = 0\nans = 0\nfor key in sorted(cnt.keys()):\n if cnt[key] == 0:\n continue\n if prev == -100:\n prev = key\n if (key - prev) < 2:\n cur += cnt[key]\n else:\n cur = cnt[key]\n ans += cur // 2\n cur -= 2 * (cur // 2)\n prev = key\nprint(ans)\n", "code_v1_no_empty_lines": "import sys\n\nstdin = sys.stdin\nsys.setrecursionlimit(10**7)\n\n\ndef li():\n return list(map(int, stdin.readline().split()))\n\n\ndef li_():\n return [int(x) - 1 for x in stdin.readline().split()]\n\n\ndef lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef ls():\n return stdin.readline().split()\n\n\ndef ns():\n return stdin.readline().rstrip()\n\n\ndef lc():\n return list(ns())\n\n\ndef ni():\n return int(stdin.readline())\n\n\ndef nf():\n return float(stdin.readline())\n\n\nn = ni()\nans = 0\nplus = 0\na = [ni() for _ in range(n)]\nfor ai in a:\n ans += (ai + plus) // 2\n plus = (ai + plus) % 2 if ai > 0 else 0\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 39.0243902439, "diff": ["-sys.setrecursionlimit(10**8)", "+sys.setrecursionlimit(10**7)", "+ans = 0", "+plus = 0", "-cnt = {i + 1: ai for i, ai in enumerate(a)}", "-prev = -100", "-cur = 0", "-ans = 0", "-for key in sorted(cnt.keys()):", "- if cnt[key] == 0:", "- continue", "- if prev == -100:", "- prev = key", "- if (key - prev) < 2:", "- cur += cnt[key]", "- else:", "- cur = cnt[key]", "- ans += cur // 2", "- cur -= 2 * (cur // 2)", "- prev = key", "+for ai in a:", "+ ans += (ai + plus) // 2", "+ plus = (ai + plus) % 2 if ai > 0 else 0"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2743015865, "measured_runtime_v1": 0.1203746786, "runtime_lift": 2.278731621, "key": ["s879592559", "s107006666"]} {"user_id": "u761529120", "problem_id": "p03164", "language": "python", "submission_id_v0": "s478711084", "submission_id_v1": "s154638745", "cpu_time_v0": 1151, "cpu_time_v1": 682, "memory_v0": 312192, "memory_v1": 334552, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 40.75, "input": "def main():\n\n N, W = list(map(int, input().split()))\n\n w = [0] * N\n\n v = [0] * N\n\n for i in range(N):\n\n w[i], v[i] = list(map(int, input().split()))\n\n\n\n max_v = max(v)\n\n dp = [[float('inf')] * (max_v * N + 5) for _ in range(N + 5)]\n\n\n\n dp[0][0] = 0\n\n\n\n for i in range(N):\n\n for j in range(max_v * N):\n\n if j + v[i] <= max_v * N:\n\n dp[i+1][j + v[i]] = min(dp[i+1][j + v[i]], dp[i][j] + w[i])\n\n dp[i+1][j] = min(dp[i+1][j], dp[i][j]) \n\n\n\n ans = 0\n\n for j in range(max_v * N + 1):\n\n if dp[N][j] <= W:\n\n ans = j\n\n\n\n print(ans)\n\n\n\nif __name__ == \"__main__\":\n\n main()", "target": "def main():\n\n N, W = list(map(int, input().split()))\n\n weight = [0] * N\n\n value = [0] * N\n\n for i in range(N):\n\n weight[i], value[i] = list(map(int, input().split()))\n\n V = sum(value)\n\n dp = [[float('inf')] * (V + 5) for _ in range(N + 5)]\n\n dp[0][0] = 0\n\n for i in range(N):\n\n for v in range(V+1):\n\n if v - value[i] >= 0:\n\n dp[i+1][v] = min(dp[i][v-value[i]] + weight[i], dp[i][v])\n\n else:\n\n dp[i+1][v] = dp[i][v]\n\n ans = 0\n\n for v in range(V+1):\n\n if dp[N][v] <= W:\n\n ans = v\n\n print(ans)\n\n\n\nif __name__ == \"__main__\":\n\n main()", "code_v0_loc": 27, "code_v1_loc": 23, "code_v0_num_chars": 654, "code_v1_num_chars": 637, "code_v0_no_empty_lines": "def main():\n N, W = list(map(int, input().split()))\n w = [0] * N\n v = [0] * N\n for i in range(N):\n w[i], v[i] = list(map(int, input().split()))\n max_v = max(v)\n dp = [[float(\"inf\")] * (max_v * N + 5) for _ in range(N + 5)]\n dp[0][0] = 0\n for i in range(N):\n for j in range(max_v * N):\n if j + v[i] <= max_v * N:\n dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i])\n dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])\n ans = 0\n for j in range(max_v * N + 1):\n if dp[N][j] <= W:\n ans = j\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n N, W = list(map(int, input().split()))\n weight = [0] * N\n value = [0] * N\n for i in range(N):\n weight[i], value[i] = list(map(int, input().split()))\n V = sum(value)\n dp = [[float(\"inf\")] * (V + 5) for _ in range(N + 5)]\n dp[0][0] = 0\n for i in range(N):\n for v in range(V + 1):\n if v - value[i] >= 0:\n dp[i + 1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v])\n else:\n dp[i + 1][v] = dp[i][v]\n ans = 0\n for v in range(V + 1):\n if dp[N][v] <= W:\n ans = v\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 14.8148148148, "diff": ["- w = [0] * N", "- v = [0] * N", "+ weight = [0] * N", "+ value = [0] * N", "- w[i], v[i] = list(map(int, input().split()))", "- max_v = max(v)", "- dp = [[float(\"inf\")] * (max_v * N + 5) for _ in range(N + 5)]", "+ weight[i], value[i] = list(map(int, input().split()))", "+ V = sum(value)", "+ dp = [[float(\"inf\")] * (V + 5) for _ in range(N + 5)]", "- for j in range(max_v * N):", "- if j + v[i] <= max_v * N:", "- dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i])", "- dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])", "+ for v in range(V + 1):", "+ if v - value[i] >= 0:", "+ dp[i + 1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v])", "+ else:", "+ dp[i + 1][v] = dp[i][v]", "- for j in range(max_v * N + 1):", "- if dp[N][j] <= W:", "- ans = j", "+ for v in range(V + 1):", "+ if dp[N][v] <= W:", "+ ans = v"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2676751952, "measured_runtime_v1": 0.1215952404, "runtime_lift": 2.2013624416, "key": ["s478711084", "s154638745"]} {"user_id": "u057109575", "problem_id": "p03078", "language": "python", "submission_id_v0": "s065985582", "submission_id_v1": "s294135268", "cpu_time_v0": 153, "cpu_time_v1": 124, "memory_v0": 79232, "memory_v1": 73392, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 18.95, "input": "\n\nfrom heapq import heappop, heappush\n\n\n\nX, Y, Z, K = list(map(int, input().split()))\n\nA = list(map(int, input().split()))\n\nB = list(map(int, input().split()))\n\nC = list(map(int, input().split()))\n\n\n\nA.sort(reverse=True)\n\nB.sort(reverse=True)\n\nC.sort(reverse=True)\n\n\n\npq = []\n\nheappush(pq, (-A[0] - B[0] - C[0], 0, 0, 0))\n\nappeared = set((0, 0, 0))\n\n\n\nfor _ in range(K):\n\n # Pop maximum value\n\n val, i, j, k = heappop(pq)\n\n print((-val))\n\n\n\n # Add next value\n\n if i + 1 < X and (i + 1, j, k) not in appeared:\n\n heappush(pq, (-A[i + 1] - B[j] - C[k], i + 1, j, k))\n\n appeared.add((i + 1, j, k))\n\n\n\n if j + 1 < Y and (i, j + 1, k) not in appeared:\n\n heappush(pq, (-A[i] - B[j + 1] - C[k], i, j + 1, k))\n\n appeared.add((i, j + 1, k))\n\n\n\n if k + 1 < Z and (i, j, k + 1) not in appeared:\n\n heappush(pq, (-A[i] - B[j] - C[k + 1], i, j, k + 1))\n\n appeared.add((i, j, k + 1))\n", "target": "\n\nX, Y, Z, K = list(map(int, input().split()))\n\nA = list(map(int, input().split()))\n\nB = list(map(int, input().split()))\n\nC = list(map(int, input().split()))\n\n\n\nA.sort(reverse=True)\n\nB.sort(reverse=True)\n\nC.sort(reverse=True)\n\n\n\nres = []\n\nfor i in range(X):\n\n for j in range(Y):\n\n for k in range(Z):\n\n if (i + 1) * (j + 1) * (k + 1) <= K:\n\n res.append(A[i] + B[j] + C[k])\n\n else:\n\n break\n\n\n\nres.sort(reverse=True)\n\nfor i in range(K):\n\n print((res[i]))\n", "code_v0_loc": 33, "code_v1_loc": 22, "code_v0_num_chars": 923, "code_v1_num_chars": 509, "code_v0_no_empty_lines": "from heapq import heappop, heappush\n\nX, Y, Z, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort(reverse=True)\nB.sort(reverse=True)\nC.sort(reverse=True)\npq = []\nheappush(pq, (-A[0] - B[0] - C[0], 0, 0, 0))\nappeared = set((0, 0, 0))\nfor _ in range(K):\n # Pop maximum value\n val, i, j, k = heappop(pq)\n print((-val))\n # Add next value\n if i + 1 < X and (i + 1, j, k) not in appeared:\n heappush(pq, (-A[i + 1] - B[j] - C[k], i + 1, j, k))\n appeared.add((i + 1, j, k))\n if j + 1 < Y and (i, j + 1, k) not in appeared:\n heappush(pq, (-A[i] - B[j + 1] - C[k], i, j + 1, k))\n appeared.add((i, j + 1, k))\n if k + 1 < Z and (i, j, k + 1) not in appeared:\n heappush(pq, (-A[i] - B[j] - C[k + 1], i, j, k + 1))\n appeared.add((i, j, k + 1))\n", "code_v1_no_empty_lines": "X, Y, Z, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort(reverse=True)\nB.sort(reverse=True)\nC.sort(reverse=True)\nres = []\nfor i in range(X):\n for j in range(Y):\n for k in range(Z):\n if (i + 1) * (j + 1) * (k + 1) <= K:\n res.append(A[i] + B[j] + C[k])\n else:\n break\nres.sort(reverse=True)\nfor i in range(K):\n print((res[i]))\n", "code_same": false, "relative_loc_diff_percent": 33.3333333333, "diff": ["-from heapq import heappop, heappush", "-", "-pq = []", "-heappush(pq, (-A[0] - B[0] - C[0], 0, 0, 0))", "-appeared = set((0, 0, 0))", "-for _ in range(K):", "- # Pop maximum value", "- val, i, j, k = heappop(pq)", "- print((-val))", "- # Add next value", "- if i + 1 < X and (i + 1, j, k) not in appeared:", "- heappush(pq, (-A[i + 1] - B[j] - C[k], i + 1, j, k))", "- appeared.add((i + 1, j, k))", "- if j + 1 < Y and (i, j + 1, k) not in appeared:", "- heappush(pq, (-A[i] - B[j + 1] - C[k], i, j + 1, k))", "- appeared.add((i, j + 1, k))", "- if k + 1 < Z and (i, j, k + 1) not in appeared:", "- heappush(pq, (-A[i] - B[j] - C[k + 1], i, j, k + 1))", "- appeared.add((i, j, k + 1))", "+res = []", "+for i in range(X):", "+ for j in range(Y):", "+ for k in range(Z):", "+ if (i + 1) * (j + 1) * (k + 1) <= K:", "+ res.append(A[i] + B[j] + C[k])", "+ else:", "+ break", "+res.sort(reverse=True)", "+for i in range(K):", "+ print((res[i]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3859105117, "measured_runtime_v1": 0.2075348065, "runtime_lift": 1.8594977789, "key": ["s065985582", "s294135268"]} {"user_id": "u867826040", "problem_id": "p02837", "language": "python", "submission_id_v0": "s705992872", "submission_id_v1": "s870269222", "cpu_time_v0": 258, "cpu_time_v1": 223, "memory_v0": 9120, "memory_v1": 9160, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 13.57, "input": "n = int(input())\n\nv = [[tuple(map(int, input().split()))for i in range(int(input()))]\n\n for i in range(n)]\n\n\n\nans = 0\n\nfor i in range(2**n):\n\n f = [False] * n\n\n xy = []\n\n for j in range(n):\n\n if (i >> j) & 1:\n\n f[j] = True\n\n xy.append(v[j])\n\n flag = True\n\n for xyi in xy:\n\n for x, y in xyi:\n\n if f[x - 1] is not bool(y):\n\n flag = False\n\n break\n\n if flag:\n\n ans = max(ans, len(xy))\n\nprint(ans)\n", "target": "n = int(input())\n\nv = [[tuple(map(int, input().split()))for i in range(int(input()))]\n\n for i in range(n)]\n\n\n\nans = 0\n\nfor i in range(2**n):\n\n f = [0] * n\n\n xy = []\n\n for j in range(n):\n\n if (i >> j) & 1:\n\n f[j] = 1\n\n xy.append(v[j])\n\n flag = True\n\n for xyi in xy:\n\n for x, y in xyi:\n\n #print(f,x,y,bin(i))\n\n if (i>>(x-1))&1 != y:\n\n flag = False\n\n break\n\n if flag:\n\n ans = max(ans, len(xy))\n\nprint(ans)\n", "code_v0_loc": 21, "code_v1_loc": 22, "code_v0_num_chars": 499, "code_v1_num_chars": 520, "code_v0_no_empty_lines": "n = int(input())\nv = [\n [tuple(map(int, input().split())) for i in range(int(input()))]\n for i in range(n)\n]\nans = 0\nfor i in range(2**n):\n f = [False] * n\n xy = []\n for j in range(n):\n if (i >> j) & 1:\n f[j] = True\n xy.append(v[j])\n flag = True\n for xyi in xy:\n for x, y in xyi:\n if f[x - 1] is not bool(y):\n flag = False\n break\n if flag:\n ans = max(ans, len(xy))\nprint(ans)\n", "code_v1_no_empty_lines": "n = int(input())\nv = [\n [tuple(map(int, input().split())) for i in range(int(input()))]\n for i in range(n)\n]\nans = 0\nfor i in range(2**n):\n f = [0] * n\n xy = []\n for j in range(n):\n if (i >> j) & 1:\n f[j] = 1\n xy.append(v[j])\n flag = True\n for xyi in xy:\n for x, y in xyi:\n # print(f,x,y,bin(i))\n if (i >> (x - 1)) & 1 != y:\n flag = False\n break\n if flag:\n ans = max(ans, len(xy))\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 4.5454545455, "diff": ["- f = [False] * n", "+ f = [0] * n", "- f[j] = True", "+ f[j] = 1", "- if f[x - 1] is not bool(y):", "+ # print(f,x,y,bin(i))", "+ if (i >> (x - 1)) & 1 != y:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.289290843, "measured_runtime_v1": 0.2134317408, "runtime_lift": 1.3554255893, "key": ["s705992872", "s870269222"]} {"user_id": "u998741086", "problem_id": "p03425", "language": "python", "submission_id_v0": "s570150327", "submission_id_v1": "s255248054", "cpu_time_v0": 227, "cpu_time_v1": 144, "memory_v0": 16268, "memory_v1": 16064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 36.56, "input": "#!/usr/bin/env python3\n\n\n\nn = int(input())\n\ns = [input() for _ in range(n)]\n\n\n\nc = [0 for _ in range(5)]\n\nt = 'MARCH'\n\n\n\nfor i in range(n):\n\n for j in range(5):\n\n if s[i][0] == t[j]:\n\n c[j] += 1\n\nans = 0 \n\nfor i in range(5):\n\n for j in range(i+1, 5): \n\n for k in range(j+1, 5): \n\n ans += c[i]*c[k]*c[j]\n\nprint(ans)\n", "target": "#!/usr/bin/env python3\n\n\n\nn = int(input())\n\ns = [input() for _ in range(n)]\n\nd = {}\n\n\n\nfor c in s:\n\n if c[0] not in d:\n\n d[c[0]] = 1 \n\n else:\n\n d[c[0]] += 1\n\n\n\ntmp = d.copy()\n\nt = ['M', 'A', 'R', 'C', 'H']\n\nfor c in tmp:\n\n if c not in t:\n\n d.pop(c)\n\n\n\nans = 0 \n\ndlist = list(d.items())\n\nfor i in range(len(dlist)):\n\n for j in range(i+1, len(dlist)):\n\n for k in range(j+1, len(dlist)):\n\n ans += dlist[i][1]*dlist[j][1]*dlist[k][1]\n\nprint(ans)\n", "code_v0_loc": 18, "code_v1_loc": 25, "code_v0_num_chars": 357, "code_v1_num_chars": 493, "code_v0_no_empty_lines": "#!/usr/bin/env python3\nn = int(input())\ns = [input() for _ in range(n)]\nc = [0 for _ in range(5)]\nt = \"MARCH\"\nfor i in range(n):\n for j in range(5):\n if s[i][0] == t[j]:\n c[j] += 1\nans = 0\nfor i in range(5):\n for j in range(i + 1, 5):\n for k in range(j + 1, 5):\n ans += c[i] * c[k] * c[j]\nprint(ans)\n", "code_v1_no_empty_lines": "#!/usr/bin/env python3\nn = int(input())\ns = [input() for _ in range(n)]\nd = {}\nfor c in s:\n if c[0] not in d:\n d[c[0]] = 1\n else:\n d[c[0]] += 1\ntmp = d.copy()\nt = [\"M\", \"A\", \"R\", \"C\", \"H\"]\nfor c in tmp:\n if c not in t:\n d.pop(c)\nans = 0\ndlist = list(d.items())\nfor i in range(len(dlist)):\n for j in range(i + 1, len(dlist)):\n for k in range(j + 1, len(dlist)):\n ans += dlist[i][1] * dlist[j][1] * dlist[k][1]\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 28.0, "diff": ["-c = [0 for _ in range(5)]", "-t = \"MARCH\"", "-for i in range(n):", "- for j in range(5):", "- if s[i][0] == t[j]:", "- c[j] += 1", "+d = {}", "+for c in s:", "+ if c[0] not in d:", "+ d[c[0]] = 1", "+ else:", "+ d[c[0]] += 1", "+tmp = d.copy()", "+t = [\"M\", \"A\", \"R\", \"C\", \"H\"]", "+for c in tmp:", "+ if c not in t:", "+ d.pop(c)", "-for i in range(5):", "- for j in range(i + 1, 5):", "- for k in range(j + 1, 5):", "- ans += c[i] * c[k] * c[j]", "+dlist = list(d.items())", "+for i in range(len(dlist)):", "+ for j in range(i + 1, len(dlist)):", "+ for k in range(j + 1, len(dlist)):", "+ ans += dlist[i][1] * dlist[j][1] * dlist[k][1]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3218575408, "measured_runtime_v1": 0.2488505929, "runtime_lift": 1.2933766287, "key": ["s570150327", "s255248054"]} {"user_id": "u922449550", "problem_id": "p02792", "language": "python", "submission_id_v0": "s475401488", "submission_id_v1": "s941984259", "cpu_time_v0": 197, "cpu_time_v1": 17, "memory_v0": 3188, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 91.37, "input": "N = int(input())\n\n\n\ntable = [[0]*10 for i in range(10)]\n\n\n\nfor i in range(1, N+1):\n\n s = str(i)\n\n id1 = int(s[0])\n\n id2 = int(s[-1])\n\n table[id1][id2] += 1\n\n\n\nans = 0\n\nfor i in range(10):\n\n for j in range(10):\n\n ans += table[i][j]*table[j][i]\n\n\n\nprint(ans)", "target": "N = input()\n\nm = len(N)\n\n\n\na0 = int(N[0])\n\na1 = int(N[-1])\n\n\n\nans = 0\n\nif m == 1:\n\n ans = int(N)\n\nelse:\n\n mid = (int(N[1:]) - a1)//10\n\n t = 10**(m-2)\n\n ans = 9\n\n ans += ((a0-1)*t) * 2\n\n ans += (mid + (a1>=a0)) * 2\n\n ans += ((a0-1)*t)**2\n\n ans += ((mid*(a0-1) + min(a0-1, a1))*t) * 2\n\n ans += (mid + (a1>=a0))**2\n\n if m >= 3:\n\n ans += (t - 1) * 2\n\n ans += ((a0-1)*(t - 1)*t) * 2\n\n ans += (mid * (t - 1)) * 2\n\n ans += (a1 * (t - 1)//9) * 2\n\n ans += (t - 1)**2\n\n\n\nprint(ans)", "code_v0_loc": 16, "code_v1_loc": 26, "code_v0_num_chars": 264, "code_v1_num_chars": 496, "code_v0_no_empty_lines": "N = int(input())\ntable = [[0] * 10 for i in range(10)]\nfor i in range(1, N + 1):\n s = str(i)\n id1 = int(s[0])\n id2 = int(s[-1])\n table[id1][id2] += 1\nans = 0\nfor i in range(10):\n for j in range(10):\n ans += table[i][j] * table[j][i]\nprint(ans)\n", "code_v1_no_empty_lines": "N = input()\nm = len(N)\na0 = int(N[0])\na1 = int(N[-1])\nans = 0\nif m == 1:\n ans = int(N)\nelse:\n mid = (int(N[1:]) - a1) // 10\n t = 10 ** (m - 2)\n ans = 9\n ans += ((a0 - 1) * t) * 2\n ans += (mid + (a1 >= a0)) * 2\n ans += ((a0 - 1) * t) ** 2\n ans += ((mid * (a0 - 1) + min(a0 - 1, a1)) * t) * 2\n ans += (mid + (a1 >= a0)) ** 2\n if m >= 3:\n ans += (t - 1) * 2\n ans += ((a0 - 1) * (t - 1) * t) * 2\n ans += (mid * (t - 1)) * 2\n ans += (a1 * (t - 1) // 9) * 2\n ans += (t - 1) ** 2\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 38.4615384615, "diff": ["-N = int(input())", "-table = [[0] * 10 for i in range(10)]", "-for i in range(1, N + 1):", "- s = str(i)", "- id1 = int(s[0])", "- id2 = int(s[-1])", "- table[id1][id2] += 1", "+N = input()", "+m = len(N)", "+a0 = int(N[0])", "+a1 = int(N[-1])", "-for i in range(10):", "- for j in range(10):", "- ans += table[i][j] * table[j][i]", "+if m == 1:", "+ ans = int(N)", "+else:", "+ mid = (int(N[1:]) - a1) // 10", "+ t = 10 ** (m - 2)", "+ ans = 9", "+ ans += ((a0 - 1) * t) * 2", "+ ans += (mid + (a1 >= a0)) * 2", "+ ans += ((a0 - 1) * t) ** 2", "+ ans += ((mid * (a0 - 1) + min(a0 - 1, a1)) * t) * 2", "+ ans += (mid + (a1 >= a0)) ** 2", "+ if m >= 3:", "+ ans += (t - 1) * 2", "+ ans += ((a0 - 1) * (t - 1) * t) * 2", "+ ans += (mid * (t - 1)) * 2", "+ ans += (a1 * (t - 1) // 9) * 2", "+ ans += (t - 1) ** 2"], "diff_only_import_comment": false, "measured_runtime_v0": 0.589133962, "measured_runtime_v1": 0.3507217311, "runtime_lift": 1.6797760439, "key": ["s475401488", "s941984259"]} {"user_id": "u576432509", "problem_id": "p03575", "language": "python", "submission_id_v0": "s579377069", "submission_id_v1": "s043222526", "cpu_time_v0": 33, "cpu_time_v1": 26, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 21.21, "input": "icase=0\n\nif icase==0:\n\n n,m=list(map(int, input().split()))\n\n a=[]\n\n b=[]\n\n for i in range(m):\n\n ai,bi=list(map(int, input().split()))\n\n a.append(ai)\n\n b.append(bi)\n\nelif icase==1:\n\n n=6\n\n m=5\n\n# a=[[1],[2],[3],[4],[5]]\n\n# b=[[2],[3],[4],[5],[6]]\n\n a=[1,2,3,4,5]\n\n b=[2,3,4,5,6]\n\nelif icase==2:\n\n n=7\n\n m=7\n\n a=[1,2,3,4,4,5,6]\n\n b=[3,7,4,5,6,6,7]\n\n\n\n \n\nvtx=[]\n\nfor i in range(n):\n\n vtx.append([i+1])\n\nicnt=0\n\n\n\nfor j in range(m): \n\n vtx1=vtx.copy()\n\n a1=a.copy()\n\n b1=b.copy()\n\n del a1[j]\n\n del b1[j]\n\n \n\n for i in range(m-1):\n\n for v1 in vtx1:\n\n if a1[i] in v1:\n\n if not b1[i] in v1:\n\n for v2 in vtx1:\n\n if v1!=v2:\n\n if b1[i] in v2:\n\n break\n\n vtx1.remove(v1)\n\n vtx1.remove(v2)\n\n v3=v1+v2\n\n vtx1.append(v3)\n\n# print(a[i],b[i],len(vtx1),vtx1)\n\n# print(len(vtx1),vtx1)\n\n if len(vtx1)!=1:\n\n icnt=icnt+1\n\nprint(icnt) ", "target": "limit=50\n\ngraph=[[False]*limit for i in range(limit)]\n\nvisited=[]*limit\n\n\n\ndef dfs(v,n,graph,visited):\n\n visited[v]=True\n\n for v2 in range(n):\n\n if graph[v][v2]==False:\n\n continue\n\n if visited[v2]==True:\n\n continue\n\n dfs(v2,n,graph,visited)\n\n\n\nn,m=list(map(int,input().split()))\n\na=[0]*m\n\nb=[0]*m\n\nfor i in range(m):\n\n ai,bi=list(map(int,input().split()))\n\n a[i]=ai-1\n\n b[i]=bi-1\n\n graph[a[i]][b[i]]=True\n\n graph[b[i]][a[i]]=True\n\n \n\nans=0 \n\nfor i in range(m):\n\n graph[a[i]][b[i]]=False\n\n graph[b[i]][a[i]]=False\n\n visited=[False]*n\n\n dfs(0,n,graph,visited)\n\n bridge=False\n\n for j in range(n):\n\n if visited[j]==False:\n\n bridge=True\n\n if bridge:\n\n ans+=1\n\n graph[a[i]][b[i]]=True\n\n graph[b[i]][a[i]]=True\n\n \n\nprint(ans)", "code_v0_loc": 52, "code_v1_loc": 39, "code_v0_num_chars": 1130, "code_v1_num_chars": 828, "code_v0_no_empty_lines": "icase = 0\nif icase == 0:\n n, m = list(map(int, input().split()))\n a = []\n b = []\n for i in range(m):\n ai, bi = list(map(int, input().split()))\n a.append(ai)\n b.append(bi)\nelif icase == 1:\n n = 6\n m = 5\n # a=[[1],[2],[3],[4],[5]]\n # b=[[2],[3],[4],[5],[6]]\n a = [1, 2, 3, 4, 5]\n b = [2, 3, 4, 5, 6]\nelif icase == 2:\n n = 7\n m = 7\n a = [1, 2, 3, 4, 4, 5, 6]\n b = [3, 7, 4, 5, 6, 6, 7]\nvtx = []\nfor i in range(n):\n vtx.append([i + 1])\nicnt = 0\nfor j in range(m):\n vtx1 = vtx.copy()\n a1 = a.copy()\n b1 = b.copy()\n del a1[j]\n del b1[j]\n for i in range(m - 1):\n for v1 in vtx1:\n if a1[i] in v1:\n if not b1[i] in v1:\n for v2 in vtx1:\n if v1 != v2:\n if b1[i] in v2:\n break\n vtx1.remove(v1)\n vtx1.remove(v2)\n v3 = v1 + v2\n vtx1.append(v3)\n # print(a[i],b[i],len(vtx1),vtx1)\n # print(len(vtx1),vtx1)\n if len(vtx1) != 1:\n icnt = icnt + 1\nprint(icnt)\n", "code_v1_no_empty_lines": "limit = 50\ngraph = [[False] * limit for i in range(limit)]\nvisited = [] * limit\n\n\ndef dfs(v, n, graph, visited):\n visited[v] = True\n for v2 in range(n):\n if graph[v][v2] == False:\n continue\n if visited[v2] == True:\n continue\n dfs(v2, n, graph, visited)\n\n\nn, m = list(map(int, input().split()))\na = [0] * m\nb = [0] * m\nfor i in range(m):\n ai, bi = list(map(int, input().split()))\n a[i] = ai - 1\n b[i] = bi - 1\n graph[a[i]][b[i]] = True\n graph[b[i]][a[i]] = True\nans = 0\nfor i in range(m):\n graph[a[i]][b[i]] = False\n graph[b[i]][a[i]] = False\n visited = [False] * n\n dfs(0, n, graph, visited)\n bridge = False\n for j in range(n):\n if visited[j] == False:\n bridge = True\n if bridge:\n ans += 1\n graph[a[i]][b[i]] = True\n graph[b[i]][a[i]] = True\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 25.0, "diff": ["-icase = 0", "-if icase == 0:", "- n, m = list(map(int, input().split()))", "- a = []", "- b = []", "- for i in range(m):", "- ai, bi = list(map(int, input().split()))", "- a.append(ai)", "- b.append(bi)", "-elif icase == 1:", "- n = 6", "- m = 5", "- # a=[[1],[2],[3],[4],[5]]", "- # b=[[2],[3],[4],[5],[6]]", "- a = [1, 2, 3, 4, 5]", "- b = [2, 3, 4, 5, 6]", "-elif icase == 2:", "- n = 7", "- m = 7", "- a = [1, 2, 3, 4, 4, 5, 6]", "- b = [3, 7, 4, 5, 6, 6, 7]", "-vtx = []", "-for i in range(n):", "- vtx.append([i + 1])", "-icnt = 0", "-for j in range(m):", "- vtx1 = vtx.copy()", "- a1 = a.copy()", "- b1 = b.copy()", "- del a1[j]", "- del b1[j]", "- for i in range(m - 1):", "- for v1 in vtx1:", "- if a1[i] in v1:", "- if not b1[i] in v1:", "- for v2 in vtx1:", "- if v1 != v2:", "- if b1[i] in v2:", "- break", "- vtx1.remove(v1)", "- vtx1.remove(v2)", "- v3 = v1 + v2", "- vtx1.append(v3)", "- # print(a[i],b[i],len(vtx1),vtx1)", "- # print(len(vtx1),vtx1)", "- if len(vtx1) != 1:", "- icnt = icnt + 1", "-print(icnt)", "+limit = 50", "+graph = [[False] * limit for i in range(limit)]", "+visited = [] * limit", "+", "+", "+def dfs(v, n, graph, visited):", "+ visited[v] = True", "+ for v2 in range(n):", "+ if graph[v][v2] == False:", "+ continue", "+ if visited[v2] == True:", "+ continue", "+ dfs(v2, n, graph, visited)", "+", "+", "+n, m = list(map(int, input().split()))", "+a = [0] * m", "+b = [0] * m", "+for i in range(m):", "+ ai, bi = list(map(int, input().split()))", "+ a[i] = ai - 1", "+ b[i] = bi - 1", "+ graph[a[i]][b[i]] = True", "+ graph[b[i]][a[i]] = True", "+ans = 0", "+for i in range(m):", "+ graph[a[i]][b[i]] = False", "+ graph[b[i]][a[i]] = False", "+ visited = [False] * n", "+ dfs(0, n, graph, visited)", "+ bridge = False", "+ for j in range(n):", "+ if visited[j] == False:", "+ bridge = True", "+ if bridge:", "+ ans += 1", "+ graph[a[i]][b[i]] = True", "+ graph[b[i]][a[i]] = True", "+print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3351877429, "measured_runtime_v1": 0.2583705549, "runtime_lift": 1.2973140188, "key": ["s579377069", "s043222526"]} {"user_id": "u310381103", "problem_id": "p03457", "language": "python", "submission_id_v0": "s861400279", "submission_id_v1": "s171825130", "cpu_time_v0": 647, "cpu_time_v1": 294, "memory_v0": 63064, "memory_v1": 27216, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 54.56, "input": "N=input()\n\na=[]\n\nt=True\n\nfor _ in range(int(N)):\n\n a+=[list(map(int,input().split()))]\n\nfor i in range(int(N)):\n\n if a[i][0]%2==0:\n\n if abs(a[i][1]+a[i][2])<=a[i][0] and (a[i][1]+a[i][2])%2==0:\n\n continue\n\n else:\n\n print('No')\n\n t=False\n\n break\n\n else:\n\n if abs(a[i][1]+a[i][2]<=a[i][0]) and (a[i][1]+a[i][2])%2==1:\n\n continue\n\n else:\n\n print('No')\n\n t=False\n\n break\n\nif t:\n\n print('Yes')", "target": "import sys\n\nn=int(input())\n\nt=[]\n\nfor i in range(n):\n\n t.append(list(map(int,input().split())))\n\nfor i,d in enumerate(t):\n\n if i>0:\n\n b=d[0]-a\n\n c=abs(d[1]+d[2]-aa)\n\n a=d[0]\n\n aa=d[1]+d[2]\n\n if i==0:\n\n if not (a >= aa and a % 2 == aa % 2):\n\n print('No')\n\n sys.exit()\n\n else:\n\n continue\n\n if not (b>=c and b%2==c%2):\n\n print('No')\n\n sys.exit()\n\nprint('Yes')", "code_v0_loc": 22, "code_v1_loc": 21, "code_v0_num_chars": 516, "code_v1_num_chars": 449, "code_v0_no_empty_lines": "N = input()\na = []\nt = True\nfor _ in range(int(N)):\n a += [list(map(int, input().split()))]\nfor i in range(int(N)):\n if a[i][0] % 2 == 0:\n if abs(a[i][1] + a[i][2]) <= a[i][0] and (a[i][1] + a[i][2]) % 2 == 0:\n continue\n else:\n print(\"No\")\n t = False\n break\n else:\n if abs(a[i][1] + a[i][2] <= a[i][0]) and (a[i][1] + a[i][2]) % 2 == 1:\n continue\n else:\n print(\"No\")\n t = False\n break\nif t:\n print(\"Yes\")\n", "code_v1_no_empty_lines": "import sys\n\nn = int(input())\nt = []\nfor i in range(n):\n t.append(list(map(int, input().split())))\nfor i, d in enumerate(t):\n if i > 0:\n b = d[0] - a\n c = abs(d[1] + d[2] - aa)\n a = d[0]\n aa = d[1] + d[2]\n if i == 0:\n if not (a >= aa and a % 2 == aa % 2):\n print(\"No\")\n sys.exit()\n else:\n continue\n if not (b >= c and b % 2 == c % 2):\n print(\"No\")\n sys.exit()\nprint(\"Yes\")\n", "code_same": false, "relative_loc_diff_percent": 4.5454545455, "diff": ["-N = input()", "-a = []", "-t = True", "-for _ in range(int(N)):", "- a += [list(map(int, input().split()))]", "-for i in range(int(N)):", "- if a[i][0] % 2 == 0:", "- if abs(a[i][1] + a[i][2]) <= a[i][0] and (a[i][1] + a[i][2]) % 2 == 0:", "+import sys", "+", "+n = int(input())", "+t = []", "+for i in range(n):", "+ t.append(list(map(int, input().split())))", "+for i, d in enumerate(t):", "+ if i > 0:", "+ b = d[0] - a", "+ c = abs(d[1] + d[2] - aa)", "+ a = d[0]", "+ aa = d[1] + d[2]", "+ if i == 0:", "+ if not (a >= aa and a % 2 == aa % 2):", "+ print(\"No\")", "+ sys.exit()", "+ else:", "- else:", "- print(\"No\")", "- t = False", "- break", "- else:", "- if abs(a[i][1] + a[i][2] <= a[i][0]) and (a[i][1] + a[i][2]) % 2 == 1:", "- continue", "- else:", "- print(\"No\")", "- t = False", "- break", "-if t:", "- print(\"Yes\")", "+ if not (b >= c and b % 2 == c % 2):", "+ print(\"No\")", "+ sys.exit()", "+print(\"Yes\")"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2371032157, "measured_runtime_v1": 0.0063223619, "runtime_lift": 37.5023159605, "key": ["s861400279", "s171825130"]} {"user_id": "u057109575", "problem_id": "p03579", "language": "python", "submission_id_v0": "s986959512", "submission_id_v1": "s945473888", "cpu_time_v0": 918, "cpu_time_v1": 684, "memory_v0": 108376, "memory_v1": 76248, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.49, "input": "import sys\n\nsys.setrecursionlimit(100000)\n\nN, M = list(map(int, input().split()))\n\nedges = [list(map(int, input().split())) for _ in range(M)]\n\n\n\ngraph = [[] for _ in range(N)]\n\nfor x, y in edges:\n\n graph[x - 1].append(y - 1)\n\n graph[y - 1].append(x - 1)\n\n\n\ndef dfs(v, c):\n\n # c: color = 1 or -1\n\n node[v] = c\n\n for i in graph[v]:\n\n if node[i] == c:\n\n return False\n\n \n\n if node[i] == 0 and not dfs(i, -c):\n\n return False\n\n \n\n return True\n\n\n\nnode = [0] * N\n\nif dfs(0, 1):\n\n x = sum(v + 1 for v in node) // 2\n\n print((x * (N - x) - M))\n\nelse:\n\n print((N * (N - 1) // 2 - M))\n", "target": "from collections import deque\n\nN, M = list(map(int, input().split()))\n\nedges = [list(map(int, input().split())) for _ in range(M)]\n\n\n\ngraph = [[] for _ in range(N)]\n\nfor x, y in edges:\n\n graph[x - 1].append(y - 1)\n\n graph[y - 1].append(x - 1)\n\n\n\ndef dfs(s, c):\n\n q = deque()\n\n q.append(s)\n\n visited[s] = True\n\n color[s] = c\n\n \n\n while len(q) > 0:\n\n v = q.pop()\n\n for i in graph[v]:\n\n if visited[i] and color[i] == color[v]:\n\n return False\n\n \n\n if not visited[i]:\n\n visited[i] = True\n\n color[i] = -color[v]\n\n q.append(i)\n\n \n\n return True\n\n\n\nvisited = [False] * N\n\ncolor = [0] * N\n\n\n\nif dfs(0, 1):\n\n x = sum(v + 1 for v in color) // 2\n\n print((x * (N - x) - M))\n\nelse:\n\n print((N * (N - 1) // 2 - M))\n\n \n\n ", "code_v0_loc": 28, "code_v1_loc": 38, "code_v0_num_chars": 640, "code_v1_num_chars": 858, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(100000)\nN, M = list(map(int, input().split()))\nedges = [list(map(int, input().split())) for _ in range(M)]\ngraph = [[] for _ in range(N)]\nfor x, y in edges:\n graph[x - 1].append(y - 1)\n graph[y - 1].append(x - 1)\n\n\ndef dfs(v, c):\n # c: color = 1 or -1\n node[v] = c\n for i in graph[v]:\n if node[i] == c:\n return False\n if node[i] == 0 and not dfs(i, -c):\n return False\n return True\n\n\nnode = [0] * N\nif dfs(0, 1):\n x = sum(v + 1 for v in node) // 2\n print((x * (N - x) - M))\nelse:\n print((N * (N - 1) // 2 - M))\n", "code_v1_no_empty_lines": "from collections import deque\n\nN, M = list(map(int, input().split()))\nedges = [list(map(int, input().split())) for _ in range(M)]\ngraph = [[] for _ in range(N)]\nfor x, y in edges:\n graph[x - 1].append(y - 1)\n graph[y - 1].append(x - 1)\n\n\ndef dfs(s, c):\n q = deque()\n q.append(s)\n visited[s] = True\n color[s] = c\n while len(q) > 0:\n v = q.pop()\n for i in graph[v]:\n if visited[i] and color[i] == color[v]:\n return False\n if not visited[i]:\n visited[i] = True\n color[i] = -color[v]\n q.append(i)\n return True\n\n\nvisited = [False] * N\ncolor = [0] * N\nif dfs(0, 1):\n x = sum(v + 1 for v in color) // 2\n print((x * (N - x) - M))\nelse:\n print((N * (N - 1) // 2 - M))\n", "code_same": false, "relative_loc_diff_percent": 26.3157894737, "diff": ["-import sys", "+from collections import deque", "-sys.setrecursionlimit(100000)", "-def dfs(v, c):", "- # c: color = 1 or -1", "- node[v] = c", "- for i in graph[v]:", "- if node[i] == c:", "- return False", "- if node[i] == 0 and not dfs(i, -c):", "- return False", "+def dfs(s, c):", "+ q = deque()", "+ q.append(s)", "+ visited[s] = True", "+ color[s] = c", "+ while len(q) > 0:", "+ v = q.pop()", "+ for i in graph[v]:", "+ if visited[i] and color[i] == color[v]:", "+ return False", "+ if not visited[i]:", "+ visited[i] = True", "+ color[i] = -color[v]", "+ q.append(i)", "-node = [0] * N", "+visited = [False] * N", "+color = [0] * N", "- x = sum(v + 1 for v in node) // 2", "+ x = sum(v + 1 for v in color) // 2"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2537954175, "measured_runtime_v1": 0.006062909, "runtime_lift": 41.8603372027, "key": ["s986959512", "s945473888"]} {"user_id": "u312025627", "problem_id": "p03457", "language": "python", "submission_id_v0": "s103328073", "submission_id_v1": "s130173321", "cpu_time_v0": 250, "cpu_time_v1": 183, "memory_v0": 55644, "memory_v1": 21108, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 26.8, "input": "def main():\n\n import sys\n\n input = sys.stdin.buffer.readline\n\n N = int(input())\n\n TXY = [[int(i) for i in input().split()] for j in range(N)]\n\n time, px, py = 0, 0, 0\n\n for t, x, y in TXY:\n\n move = abs(x-px) + abs(y-py)\n\n # print(move, t-time)\n\n if (t - time) % 2 != move % 2 or t - time < move:\n\n return print(\"No\")\n\n time, px, py = t, x, y\n\n print(\"Yes\")\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "def main():\n\n import sys\n\n input = sys.stdin.buffer.readline\n\n N = int(input())\n\n TXY = [[int(i) for i in input().split()] for j in range(N)]\n\n time = 0\n\n px = 0\n\n py = 0\n\n for t, x, y in TXY:\n\n move = abs(py-y) + abs(px - x)\n\n if (t-time) < move or (t - time) % 2 != move % 2:\n\n return print(\"No\")\n\n time = t\n\n px = x\n\n py = y\n\n print(\"Yes\")\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 17, "code_v1_loc": 20, "code_v0_num_chars": 461, "code_v1_num_chars": 460, "code_v0_no_empty_lines": "def main():\n import sys\n\n input = sys.stdin.buffer.readline\n N = int(input())\n TXY = [[int(i) for i in input().split()] for j in range(N)]\n time, px, py = 0, 0, 0\n for t, x, y in TXY:\n move = abs(x - px) + abs(y - py)\n # print(move, t-time)\n if (t - time) % 2 != move % 2 or t - time < move:\n return print(\"No\")\n time, px, py = t, x, y\n print(\"Yes\")\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n import sys\n\n input = sys.stdin.buffer.readline\n N = int(input())\n TXY = [[int(i) for i in input().split()] for j in range(N)]\n time = 0\n px = 0\n py = 0\n for t, x, y in TXY:\n move = abs(py - y) + abs(px - x)\n if (t - time) < move or (t - time) % 2 != move % 2:\n return print(\"No\")\n time = t\n px = x\n py = y\n print(\"Yes\")\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 15.0, "diff": ["- time, px, py = 0, 0, 0", "+ time = 0", "+ px = 0", "+ py = 0", "- move = abs(x - px) + abs(y - py)", "- # print(move, t-time)", "- if (t - time) % 2 != move % 2 or t - time < move:", "+ move = abs(py - y) + abs(px - x)", "+ if (t - time) < move or (t - time) % 2 != move % 2:", "- time, px, py = t, x, y", "+ time = t", "+ px = x", "+ py = y"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3387642326, "measured_runtime_v1": 0.1945750663, "runtime_lift": 1.7410464712, "key": ["s103328073", "s130173321"]} {"user_id": "u408071652", "problem_id": "p03078", "language": "python", "submission_id_v0": "s229462844", "submission_id_v1": "s240353408", "cpu_time_v0": 159, "cpu_time_v1": 114, "memory_v0": 72796, "memory_v1": 80804, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 28.3, "input": "import sys\n\nimport heapq\n\n\n\n\n\n# \\n\n\ndef input():\n\n return sys.stdin.readline().rstrip()\n\n\n\n\n\ndef main():\n\n X, Y, Z, K = list(map(int, input().split()))\n\n A = list(map(int, input().split()))\n\n B = list(map(int, input().split()))\n\n C = list(map(int, input().split()))\n\n\n\n A.sort(reverse=True)\n\n B.sort(reverse=True)\n\n C.sort(reverse=True)\n\n\n\n Q = []\n\n S = set()\n\n heapq.heapify(Q)\n\n heapq.heappush(Q, (-A[0] - B[0] - C[0], 0, 0, 0))\n\n for i in range(K):\n\n m, a, b, c = heapq.heappop(Q)\n\n print((-m))\n\n if (a + 1, b, c) not in S and a + 1 < X:\n\n heapq.heappush(Q, (-A[a + 1] - B[b] - C[c], a + 1, b, c))\n\n S.add((a + 1, b, c))\n\n if (a, b + 1, c) not in S and b + 1 < Y:\n\n heapq.heappush(Q, (-A[a] - B[b + 1] - C[c], a, b + 1, c))\n\n S.add((a, b + 1, c))\n\n if (a, b, c + 1) not in S and c + 1 < Z:\n\n heapq.heappush(Q, (-A[a ] - B[b] - C[c+1], a, b, c + 1))\n\n S.add((a, b, c + 1))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "import sys\n\n\n\n\n\n# \\n\n\ndef input():\n\n return sys.stdin.readline().rstrip()\n\n\n\n\n\ndef main():\n\n X, Y, Z, K = list(map(int, input().split()))\n\n A = list(map(int, input().split()))\n\n B = list(map(int, input().split()))\n\n C = list(map(int, input().split()))\n\n\n\n A.sort(reverse=True)\n\n B.sort(reverse=True)\n\n C.sort(reverse=True)\n\n\n\n L = []\n\n\n\n for i in range(X):\n\n for j in range(min(Y, K // (i + 1) + 1)):\n\n for k in range(min(Z, K // (i + 1) // (j + 1) + 1)):\n\n L.append(A[i] + B[j] + C[k])\n\n\n\n L.sort(reverse=True)\n\n\n\n for i in range(K):\n\n print((L[i]))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "code_v0_loc": 39, "code_v1_loc": 33, "code_v0_num_chars": 1051, "code_v1_num_chars": 663, "code_v0_no_empty_lines": "import sys\nimport heapq\n\n# \\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef main():\n X, Y, Z, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n C = list(map(int, input().split()))\n A.sort(reverse=True)\n B.sort(reverse=True)\n C.sort(reverse=True)\n Q = []\n S = set()\n heapq.heapify(Q)\n heapq.heappush(Q, (-A[0] - B[0] - C[0], 0, 0, 0))\n for i in range(K):\n m, a, b, c = heapq.heappop(Q)\n print((-m))\n if (a + 1, b, c) not in S and a + 1 < X:\n heapq.heappush(Q, (-A[a + 1] - B[b] - C[c], a + 1, b, c))\n S.add((a + 1, b, c))\n if (a, b + 1, c) not in S and b + 1 < Y:\n heapq.heappush(Q, (-A[a] - B[b + 1] - C[c], a, b + 1, c))\n S.add((a, b + 1, c))\n if (a, b, c + 1) not in S and c + 1 < Z:\n heapq.heappush(Q, (-A[a] - B[b] - C[c + 1], a, b, c + 1))\n S.add((a, b, c + 1))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\n\n# \\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef main():\n X, Y, Z, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n C = list(map(int, input().split()))\n A.sort(reverse=True)\n B.sort(reverse=True)\n C.sort(reverse=True)\n L = []\n for i in range(X):\n for j in range(min(Y, K // (i + 1) + 1)):\n for k in range(min(Z, K // (i + 1) // (j + 1) + 1)):\n L.append(A[i] + B[j] + C[k])\n L.sort(reverse=True)\n for i in range(K):\n print((L[i]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 15.3846153846, "diff": ["-import heapq", "- Q = []", "- S = set()", "- heapq.heapify(Q)", "- heapq.heappush(Q, (-A[0] - B[0] - C[0], 0, 0, 0))", "+ L = []", "+ for i in range(X):", "+ for j in range(min(Y, K // (i + 1) + 1)):", "+ for k in range(min(Z, K // (i + 1) // (j + 1) + 1)):", "+ L.append(A[i] + B[j] + C[k])", "+ L.sort(reverse=True)", "- m, a, b, c = heapq.heappop(Q)", "- print((-m))", "- if (a + 1, b, c) not in S and a + 1 < X:", "- heapq.heappush(Q, (-A[a + 1] - B[b] - C[c], a + 1, b, c))", "- S.add((a + 1, b, c))", "- if (a, b + 1, c) not in S and b + 1 < Y:", "- heapq.heappush(Q, (-A[a] - B[b + 1] - C[c], a, b + 1, c))", "- S.add((a, b + 1, c))", "- if (a, b, c + 1) not in S and c + 1 < Z:", "- heapq.heappush(Q, (-A[a] - B[b] - C[c + 1], a, b, c + 1))", "- S.add((a, b, c + 1))", "+ print((L[i]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3053240893, "measured_runtime_v1": 0.1252524042, "runtime_lift": 2.4376704877, "key": ["s229462844", "s240353408"]} {"user_id": "u150984829", "problem_id": "p02386", "language": "python", "submission_id_v0": "s799017760", "submission_id_v1": "s414241098", "cpu_time_v0": 150, "cpu_time_v1": 130, "memory_v0": 5608, "memory_v1": 5608, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 13.33, "input": "n=int(input())\n\na=[list(map(int,input().split()))for _ in range(n)]\n\ndef f():\n\n for i in range(n-1):\n\n d=a[i][:];d[3],d[4]=d[4],d[3]\n\n for j in range(i+1,n):\n\n e=a[j][:];e[3],e[4]=e[4],e[3]\n\n for p in('012345','152043','215304','302541','410352','514320'):\n\n f=[d[int(k)]for k in p]\n\n g=f[1:5]*2\n\n for k in range(4):\n\n if(g[k:k+4]==e[1:5])*(f[0]==e[0])*(f[5]==e[5]):return 'No'\n\n return 'Yes'\n\nprint((f()))\n", "target": "n=int(input())\n\na=[list(map(int,input().split()))for _ in range(n)]\n\ndef f():\n\n for i in range(n-1):\n\n d=a[i][:];d[3],d[4]=d[4],d[3]\n\n for j in range(i+1,n):\n\n e=a[j][:];e[3],e[4]=e[4],e[3]\n\n for p in('012345','152043','215304','302541','410352','514320'):\n\n f=[d[int(k)]for k in p]\n\n g=f[1:5]*2\n\n for k in range(4):\n\n if g[k:k+4]==e[1:5]:\n\n if f[0]==e[0]:\n\n if f[5]==e[5]:return 'No'\n\n return 'Yes'\n\nprint((f()))\n", "code_v0_loc": 14, "code_v1_loc": 16, "code_v0_num_chars": 424, "code_v1_num_chars": 442, "code_v0_no_empty_lines": "n = int(input())\na = [list(map(int, input().split())) for _ in range(n)]\n\n\ndef f():\n for i in range(n - 1):\n d = a[i][:]\n d[3], d[4] = d[4], d[3]\n for j in range(i + 1, n):\n e = a[j][:]\n e[3], e[4] = e[4], e[3]\n for p in (\"012345\", \"152043\", \"215304\", \"302541\", \"410352\", \"514320\"):\n f = [d[int(k)] for k in p]\n g = f[1:5] * 2\n for k in range(4):\n if (g[k : k + 4] == e[1:5]) * (f[0] == e[0]) * (f[5] == e[5]):\n return \"No\"\n return \"Yes\"\n\n\nprint((f()))\n", "code_v1_no_empty_lines": "n = int(input())\na = [list(map(int, input().split())) for _ in range(n)]\n\n\ndef f():\n for i in range(n - 1):\n d = a[i][:]\n d[3], d[4] = d[4], d[3]\n for j in range(i + 1, n):\n e = a[j][:]\n e[3], e[4] = e[4], e[3]\n for p in (\"012345\", \"152043\", \"215304\", \"302541\", \"410352\", \"514320\"):\n f = [d[int(k)] for k in p]\n g = f[1:5] * 2\n for k in range(4):\n if g[k : k + 4] == e[1:5]:\n if f[0] == e[0]:\n if f[5] == e[5]:\n return \"No\"\n return \"Yes\"\n\n\nprint((f()))\n", "code_same": false, "relative_loc_diff_percent": 12.5, "diff": ["- if (g[k : k + 4] == e[1:5]) * (f[0] == e[0]) * (f[5] == e[5]):", "- return \"No\"", "+ if g[k : k + 4] == e[1:5]:", "+ if f[0] == e[0]:", "+ if f[5] == e[5]:", "+ return \"No\""], "diff_only_import_comment": false, "measured_runtime_v0": 0.3438470016, "measured_runtime_v1": 0.1932190149, "runtime_lift": 1.7795712385, "key": ["s799017760", "s414241098"]} {"user_id": "u716530146", "problem_id": "p03038", "language": "python", "submission_id_v0": "s839494003", "submission_id_v1": "s928697183", "cpu_time_v0": 613, "cpu_time_v1": 410, "memory_v0": 89216, "memory_v1": 43704, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 33.12, "input": "import sys\n\ninput = lambda: sys.stdin.readline()[:-1]\n\nn,m=list(map(int,input().split()))\n\na0=list(map(int,input().split()))\n\ndata=[list(map(int,input().split())) for i in range(m)]\n\nfor i in a0:\n\n\tdata.append([1,i])\n\ndata.sort(key=lambda tup:-tup[1])\n\nans=0\n\nfor num,val in data:\n\n\tif n>=num:\n\n\t\tn-=num\n\n\t\tans+=val*num\n\n\telse:\n\n\t\tans+=val*n\n\n\t\tbreak\n\nprint(ans)\n", "target": "#!/usr/bin/env python3\n\nimport sys\n\nfrom collections import Counter\n\ninput = lambda: sys.stdin.readline()[:-1]\n\nsys.setrecursionlimit(10**8)\n\n\n\nans=0\n\nn,m=list(map(int,input().split()))\n\nA=list(map(int,input().split()))\n\nbc=[]\n\nfor i in range(m):\n\n b,c=list(map(int,input().split()))\n\n bc.append((c,b))\n\nC=Counter(A)\n\nbc+=list(C.items())\n\nbc.sort(key=lambda tup:-tup[0])\n\n# print(bc)\n\nfor c,b in bc:\n\n if n>=b:\n\n n-=b\n\n ans+=c*b\n\n else:\n\n ans+=c*n\n\n break\n\nprint(ans)\n\n\n", "code_v0_loc": 17, "code_v1_loc": 26, "code_v0_num_chars": 357, "code_v1_num_chars": 498, "code_v0_no_empty_lines": "import sys\n\ninput = lambda: sys.stdin.readline()[:-1]\nn, m = list(map(int, input().split()))\na0 = list(map(int, input().split()))\ndata = [list(map(int, input().split())) for i in range(m)]\nfor i in a0:\n data.append([1, i])\ndata.sort(key=lambda tup: -tup[1])\nans = 0\nfor num, val in data:\n if n >= num:\n n -= num\n ans += val * num\n else:\n ans += val * n\n break\nprint(ans)\n", "code_v1_no_empty_lines": "#!/usr/bin/env python3\nimport sys\nfrom collections import Counter\n\ninput = lambda: sys.stdin.readline()[:-1]\nsys.setrecursionlimit(10**8)\nans = 0\nn, m = list(map(int, input().split()))\nA = list(map(int, input().split()))\nbc = []\nfor i in range(m):\n b, c = list(map(int, input().split()))\n bc.append((c, b))\nC = Counter(A)\nbc += list(C.items())\nbc.sort(key=lambda tup: -tup[0])\n# print(bc)\nfor c, b in bc:\n if n >= b:\n n -= b\n ans += c * b\n else:\n ans += c * n\n break\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 34.6153846154, "diff": ["+#!/usr/bin/env python3", "+from collections import Counter", "+sys.setrecursionlimit(10**8)", "+ans = 0", "-a0 = list(map(int, input().split()))", "-data = [list(map(int, input().split())) for i in range(m)]", "-for i in a0:", "- data.append([1, i])", "-data.sort(key=lambda tup: -tup[1])", "-ans = 0", "-for num, val in data:", "- if n >= num:", "- n -= num", "- ans += val * num", "+A = list(map(int, input().split()))", "+bc = []", "+for i in range(m):", "+ b, c = list(map(int, input().split()))", "+ bc.append((c, b))", "+C = Counter(A)", "+bc += list(C.items())", "+bc.sort(key=lambda tup: -tup[0])", "+# print(bc)", "+for c, b in bc:", "+ if n >= b:", "+ n -= b", "+ ans += c * b", "- ans += val * n", "+ ans += c * n"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2703684399, "measured_runtime_v1": 0.1342513988, "runtime_lift": 2.013896632, "key": ["s839494003", "s928697183"]} {"user_id": "u846634344", "problem_id": "p03200", "language": "python", "submission_id_v0": "s951894178", "submission_id_v1": "s605042414", "cpu_time_v0": 58, "cpu_time_v1": 51, "memory_v0": 5932, "memory_v1": 3500, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 12.07, "input": "import sys\n\nsys.setrecursionlimit(10**6)\n\nif sys.platform in (['ios','darwin','win32']):\n\n\tsys.stdin=open('Untitled.txt')\n\ninput = sys.stdin.readline\n\ndef INT(): return int(input())\n\ndef MAP(): return [int(s) for s in input().split()]\n\n\n\ndef main():\n\n\tS = input().rstrip()\n\n\tbcnt = 0\n\n\tA = []\n\n\tfor i in range(len(S)):\n\n\t\tif S[i] == 'B': bcnt += 1\n\n\t\tif S[i] == 'W': A.append(bcnt)\n\n\t\n\n\tprint((sum(A)))\n\n\n\nif __name__ == '__main__':\n\n\tmain()", "target": "import sys\n\nsys.setrecursionlimit(10**6)\n\nif sys.platform in (['ios','darwin','win32']):\n\n\tsys.stdin=open('Untitled.txt')\n\ninput = sys.stdin.readline\n\ndef INT(): return int(input())\n\ndef MAP(): return [int(s) for s in input().split()]\n\n\n\ndef main():\n\n\tS = input().rstrip()\n\n\tbcnt = 0\n\n\tans = 0\n\n\tfor i in range(len(S)):\n\n\t\tif S[i] == 'B': bcnt += 1\n\n\t\tif S[i] == 'W': ans += bcnt\n\n\t\n\n\tprint(ans)\n\n\n\nif __name__ == '__main__':\n\n\tmain()", "code_v0_loc": 20, "code_v1_loc": 20, "code_v0_num_chars": 439, "code_v1_num_chars": 434, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**6)\nif sys.platform in ([\"ios\", \"darwin\", \"win32\"]):\n sys.stdin = open(\"Untitled.txt\")\ninput = sys.stdin.readline\n\n\ndef INT():\n return int(input())\n\n\ndef MAP():\n return [int(s) for s in input().split()]\n\n\ndef main():\n S = input().rstrip()\n bcnt = 0\n A = []\n for i in range(len(S)):\n if S[i] == \"B\":\n bcnt += 1\n if S[i] == \"W\":\n A.append(bcnt)\n print((sum(A)))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**6)\nif sys.platform in ([\"ios\", \"darwin\", \"win32\"]):\n sys.stdin = open(\"Untitled.txt\")\ninput = sys.stdin.readline\n\n\ndef INT():\n return int(input())\n\n\ndef MAP():\n return [int(s) for s in input().split()]\n\n\ndef main():\n S = input().rstrip()\n bcnt = 0\n ans = 0\n for i in range(len(S)):\n if S[i] == \"B\":\n bcnt += 1\n if S[i] == \"W\":\n ans += bcnt\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- A = []", "+ ans = 0", "- A.append(bcnt)", "- print((sum(A)))", "+ ans += bcnt", "+ print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2057990801, "measured_runtime_v1": 0.0065612807, "runtime_lift": 31.365687324, "key": ["s951894178", "s605042414"]} {"user_id": "u968166680", "problem_id": "p03752", "language": "python", "submission_id_v0": "s863090450", "submission_id_v1": "s059435285", "cpu_time_v0": 32, "cpu_time_v1": 24, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.0, "input": "import sys\n\n\n\nread = sys.stdin.read\n\nreadline = sys.stdin.readline\n\nreadlines = sys.stdin.readlines\n\nsys.setrecursionlimit(10 ** 9)\n\nINF = 1 << 60\n\n\n\n\n\ndef main():\n\n N, K, *A = list(map(int, read().split()))\n\n\n\n ans = INF\n\n for bit in range(1 << N):\n\n if (not (bit & 1)) or bin(bit).count('1') != K:\n\n continue\n\n\n\n total = 0\n\n max_height = A[0]\n\n for i, a in enumerate(A[1:], 1):\n\n if a <= max_height:\n\n if bit & (1 << i):\n\n total += max_height - a + 1\n\n max_height += 1\n\n else:\n\n max_height = a\n\n\n\n if ans > total:\n\n ans = total\n\n\n\n print(ans)\n\n\n\n return\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "import sys\n\nfrom itertools import combinations\n\n\n\nread = sys.stdin.read\n\nreadline = sys.stdin.readline\n\nreadlines = sys.stdin.readlines\n\nsys.setrecursionlimit(10 ** 9)\n\nINF = 1 << 60\n\n\n\n\n\ndef main():\n\n N, K, *A = list(map(int, read().split()))\n\n\n\n ans = INF\n\n for comb in combinations(list(range(1, N)), K - 1):\n\n included = [False] * N\n\n for i in comb:\n\n included[i] = True\n\n\n\n total = 0\n\n max_height = A[0]\n\n for i, a in enumerate(A[1:], 1):\n\n if a <= max_height:\n\n if included[i]:\n\n total += max_height - a + 1\n\n max_height += 1\n\n else:\n\n max_height = a\n\n\n\n if ans > total:\n\n ans = total\n\n\n\n print(ans)\n\n\n\n return\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 37, "code_v1_loc": 39, "code_v0_num_chars": 756, "code_v1_num_chars": 818, "code_v0_no_empty_lines": "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10**9)\nINF = 1 << 60\n\n\ndef main():\n N, K, *A = list(map(int, read().split()))\n ans = INF\n for bit in range(1 << N):\n if (not (bit & 1)) or bin(bit).count(\"1\") != K:\n continue\n total = 0\n max_height = A[0]\n for i, a in enumerate(A[1:], 1):\n if a <= max_height:\n if bit & (1 << i):\n total += max_height - a + 1\n max_height += 1\n else:\n max_height = a\n if ans > total:\n ans = total\n print(ans)\n return\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\nfrom itertools import combinations\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10**9)\nINF = 1 << 60\n\n\ndef main():\n N, K, *A = list(map(int, read().split()))\n ans = INF\n for comb in combinations(list(range(1, N)), K - 1):\n included = [False] * N\n for i in comb:\n included[i] = True\n total = 0\n max_height = A[0]\n for i, a in enumerate(A[1:], 1):\n if a <= max_height:\n if included[i]:\n total += max_height - a + 1\n max_height += 1\n else:\n max_height = a\n if ans > total:\n ans = total\n print(ans)\n return\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 5.1282051282, "diff": ["+from itertools import combinations", "- for bit in range(1 << N):", "- if (not (bit & 1)) or bin(bit).count(\"1\") != K:", "- continue", "+ for comb in combinations(list(range(1, N)), K - 1):", "+ included = [False] * N", "+ for i in comb:", "+ included[i] = True", "- if bit & (1 << i):", "+ if included[i]:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4393207397, "measured_runtime_v1": 0.2213684809, "runtime_lift": 1.9845677122, "key": ["s863090450", "s059435285"]} {"user_id": "u680851063", "problem_id": "p03363", "language": "python", "submission_id_v0": "s954809041", "submission_id_v1": "s284059915", "cpu_time_v0": 905, "cpu_time_v1": 166, "memory_v0": 44692, "memory_v1": 44492, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 81.66, "input": "n = int(input())\n\nary = list(map(int, input().split()))\n\n#print(n,ary)\n\n\n\nary_2 = [ary[0]]\n\nfor i in range(1, n):\n\n ary_2.append(ary[i] + ary_2[i-1])\n\nary_2 = [0] + ary_2\n\n#print(ary_2)\n\n\n\nfrom collections import Counter\n\nc = Counter(ary_2)\n\nv = (list(c.values()))\n\n#print(v)\n\n\n\nfrom math import factorial\n\ndef combinations_count(n, r):\n\n return factorial(n) // (factorial(n - r) * factorial(r))\n\n\n\nans = 0\n\nfor j in v:\n\n if j >1:\n\n ans += combinations_count(j,2)\n\n\n\nprint(ans)", "target": "n = int(input())\n\nary = list(map(int, input().split()))\n\n#print(n,ary)\n\n\n\nary_2 = [ary[0]]\n\nfor i in range(1, n):\n\n ary_2.append(ary[i] + ary_2[i-1])\n\nary_2 = [0] + ary_2\n\n#print(ary_2)\n\n\n\nfrom collections import Counter\n\nc = Counter(ary_2)\n\nv = (list(c.values()))\n\n#print(v)\n\n\n\nans = 0\n\nfor j in v:\n\n if j >1:\n\n ans += j * (j-1) // 2\n\n\n\nprint(ans)\n", "code_v0_loc": 25, "code_v1_loc": 21, "code_v0_num_chars": 487, "code_v1_num_chars": 356, "code_v0_no_empty_lines": "n = int(input())\nary = list(map(int, input().split()))\n# print(n,ary)\nary_2 = [ary[0]]\nfor i in range(1, n):\n ary_2.append(ary[i] + ary_2[i - 1])\nary_2 = [0] + ary_2\n# print(ary_2)\nfrom collections import Counter\n\nc = Counter(ary_2)\nv = list(c.values())\n# print(v)\nfrom math import factorial\n\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\n\nans = 0\nfor j in v:\n if j > 1:\n ans += combinations_count(j, 2)\nprint(ans)\n", "code_v1_no_empty_lines": "n = int(input())\nary = list(map(int, input().split()))\n# print(n,ary)\nary_2 = [ary[0]]\nfor i in range(1, n):\n ary_2.append(ary[i] + ary_2[i - 1])\nary_2 = [0] + ary_2\n# print(ary_2)\nfrom collections import Counter\n\nc = Counter(ary_2)\nv = list(c.values())\n# print(v)\nans = 0\nfor j in v:\n if j > 1:\n ans += j * (j - 1) // 2\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 16.0, "diff": ["-from math import factorial", "-", "-", "-def combinations_count(n, r):", "- return factorial(n) // (factorial(n - r) * factorial(r))", "-", "-", "- ans += combinations_count(j, 2)", "+ ans += j * (j - 1) // 2"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2075043974, "measured_runtime_v1": 0.0060842175, "runtime_lift": 34.1053546165, "key": ["s954809041", "s284059915"]} {"user_id": "u562935282", "problem_id": "p03253", "language": "python", "submission_id_v0": "s242343005", "submission_id_v1": "s569938093", "cpu_time_v0": 72, "cpu_time_v1": 23, "memory_v0": 11380, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 68.06, "input": "class Calc:\n\n def __init__(self, max_value, mod):\n\n \"\"\"combination(max_value, all)\"\"\"\n\n fact = [-1] * (max_value + 1)\n\n fact[0] = 1\n\n fact[1] = 1\n\n for x in range(2, max_value + 1):\n\n fact[x] = x * fact[x - 1] % mod\n\n\n\n invs = [1] * (max_value + 1)\n\n invs[max_value] = pow(fact[max_value], mod - 2, mod)\n\n for x in range(max_value - 1, 0, -1):\n\n invs[x] = invs[x + 1] * (x + 1) % mod\n\n\n\n self.fact = fact\n\n self.invs = invs\n\n self.mod = mod\n\n\n\n def combination(self, n, r):\n\n if n - r < r:\n\n return self.combination(n, n - r)\n\n if r < 0:\n\n return 0\n\n if r == 0:\n\n return 1\n\n if r == 1:\n\n return n\n\n return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod\n\n\n\n\n\ndef gen(n):\n\n x = n\n\n d = 2\n\n cnt = 0\n\n while x % d == 0:\n\n x //= d\n\n cnt += 1\n\n yield cnt\n\n\n\n d = 3\n\n ma = d * d\n\n while ma <= n:\n\n cnt = 0\n\n while x % d == 0:\n\n x //= d\n\n cnt += 1\n\n yield cnt\n\n ma += d * 4 + 4\n\n d += 2\n\n\n\n if x > 1:\n\n yield 1\n\n\n\n\n\ndef main():\n\n MOD = 10 ** 9 + 7\n\n\n\n N, M = list(map(int, input().split()))\n\n\n\n cal = Calc(max_value=N + 30, mod=MOD)\n\n\n\n ans = 1\n\n for cnt in gen(M):\n\n ans = (ans * cal.combination(N + cnt - 1, cnt)) % MOD\n\n print(ans)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "def gen(n):\n\n x = n\n\n d = 2\n\n cnt = 0\n\n while x % d == 0:\n\n x //= d\n\n cnt += 1\n\n yield cnt\n\n\n\n d = 3\n\n while d * d <= n:\n\n cnt = 0\n\n while x % d == 0:\n\n x //= d\n\n cnt += 1\n\n yield cnt\n\n d += 2\n\n\n\n if x > 1:\n\n yield 1\n\n\n\n\n\ndef main():\n\n MOD = 10 ** 9 + 7\n\n\n\n N, M = list(map(int, input().split()))\n\n\n\n ans = 1\n\n for cnt in gen(M):\n\n for d in range(cnt):\n\n ans = (ans * (N - 1 + cnt - d) % MOD) * pow(d + 1, MOD - 2, MOD) % MOD\n\n \n\n print(ans)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 69, "code_v1_loc": 37, "code_v0_num_chars": 1490, "code_v1_num_chars": 619, "code_v0_no_empty_lines": "class Calc:\n def __init__(self, max_value, mod):\n \"\"\"combination(max_value, all)\"\"\"\n fact = [-1] * (max_value + 1)\n fact[0] = 1\n fact[1] = 1\n for x in range(2, max_value + 1):\n fact[x] = x * fact[x - 1] % mod\n invs = [1] * (max_value + 1)\n invs[max_value] = pow(fact[max_value], mod - 2, mod)\n for x in range(max_value - 1, 0, -1):\n invs[x] = invs[x + 1] * (x + 1) % mod\n self.fact = fact\n self.invs = invs\n self.mod = mod\n\n def combination(self, n, r):\n if n - r < r:\n return self.combination(n, n - r)\n if r < 0:\n return 0\n if r == 0:\n return 1\n if r == 1:\n return n\n return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod\n\n\ndef gen(n):\n x = n\n d = 2\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n d = 3\n ma = d * d\n while ma <= n:\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n ma += d * 4 + 4\n d += 2\n if x > 1:\n yield 1\n\n\ndef main():\n MOD = 10**9 + 7\n N, M = list(map(int, input().split()))\n cal = Calc(max_value=N + 30, mod=MOD)\n ans = 1\n for cnt in gen(M):\n ans = (ans * cal.combination(N + cnt - 1, cnt)) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def gen(n):\n x = n\n d = 2\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n d = 3\n while d * d <= n:\n cnt = 0\n while x % d == 0:\n x //= d\n cnt += 1\n yield cnt\n d += 2\n if x > 1:\n yield 1\n\n\ndef main():\n MOD = 10**9 + 7\n N, M = list(map(int, input().split()))\n ans = 1\n for cnt in gen(M):\n for d in range(cnt):\n ans = (ans * (N - 1 + cnt - d) % MOD) * pow(d + 1, MOD - 2, MOD) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 46.3768115942, "diff": ["-class Calc:", "- def __init__(self, max_value, mod):", "- \"\"\"combination(max_value, all)\"\"\"", "- fact = [-1] * (max_value + 1)", "- fact[0] = 1", "- fact[1] = 1", "- for x in range(2, max_value + 1):", "- fact[x] = x * fact[x - 1] % mod", "- invs = [1] * (max_value + 1)", "- invs[max_value] = pow(fact[max_value], mod - 2, mod)", "- for x in range(max_value - 1, 0, -1):", "- invs[x] = invs[x + 1] * (x + 1) % mod", "- self.fact = fact", "- self.invs = invs", "- self.mod = mod", "-", "- def combination(self, n, r):", "- if n - r < r:", "- return self.combination(n, n - r)", "- if r < 0:", "- return 0", "- if r == 0:", "- return 1", "- if r == 1:", "- return n", "- return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod", "-", "-", "- ma = d * d", "- while ma <= n:", "+ while d * d <= n:", "- ma += d * 4 + 4", "- cal = Calc(max_value=N + 30, mod=MOD)", "- ans = (ans * cal.combination(N + cnt - 1, cnt)) % MOD", "+ for d in range(cnt):", "+ ans = (ans * (N - 1 + cnt - d) % MOD) * pow(d + 1, MOD - 2, MOD) % MOD"], "diff_only_import_comment": false, "measured_runtime_v0": 0.5542220466, "measured_runtime_v1": 0.3755235486, "runtime_lift": 1.4758649588, "key": ["s242343005", "s569938093"]} {"user_id": "u952708174", "problem_id": "p02983", "language": "python", "submission_id_v0": "s271837395", "submission_id_v1": "s778364451", "cpu_time_v0": 612, "cpu_time_v1": 51, "memory_v0": 3060, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 91.67, "input": "def c_remainder_minimization_2019(L, R):\n\n ans = float('inf')\n\n for i in range(L, min(R, L + 2019)):\n\n for j in range(i + 1, min(R + 1, L + 2020)):\n\n ans = min(ans, (i * j) % 2019)\n\n return ans\n\n\n\nL, R = [int(i) for i in input().split()]\n\nprint((c_remainder_minimization_2019(L, R)))", "target": "def c_remainder_minimization_2019(L, R):\n\n ans = float('inf')\n\n for i in range(L, min(R, L + 2019)):\n\n for j in range(i + 1, min(R + 1, L + 2020)):\n\n ans = min(ans, (i * j) % 2019)\n\n if ans == 0:\n\n return 0\n\n return ans\n\n\n\nL, R = [int(i) for i in input().split()]\n\nprint((c_remainder_minimization_2019(L, R)))", "code_v0_loc": 9, "code_v1_loc": 11, "code_v0_num_chars": 308, "code_v1_num_chars": 360, "code_v0_no_empty_lines": "def c_remainder_minimization_2019(L, R):\n ans = float(\"inf\")\n for i in range(L, min(R, L + 2019)):\n for j in range(i + 1, min(R + 1, L + 2020)):\n ans = min(ans, (i * j) % 2019)\n return ans\n\n\nL, R = [int(i) for i in input().split()]\nprint((c_remainder_minimization_2019(L, R)))\n", "code_v1_no_empty_lines": "def c_remainder_minimization_2019(L, R):\n ans = float(\"inf\")\n for i in range(L, min(R, L + 2019)):\n for j in range(i + 1, min(R + 1, L + 2020)):\n ans = min(ans, (i * j) % 2019)\n if ans == 0:\n return 0\n return ans\n\n\nL, R = [int(i) for i in input().split()]\nprint((c_remainder_minimization_2019(L, R)))\n", "code_same": false, "relative_loc_diff_percent": 18.1818181818, "diff": ["+ if ans == 0:", "+ return 0"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3551982943, "measured_runtime_v1": 0.2038855975, "runtime_lift": 1.7421450986, "key": ["s271837395", "s778364451"]} {"user_id": "u227082700", "problem_id": "p03039", "language": "python", "submission_id_v0": "s481435936", "submission_id_v1": "s241948863", "cpu_time_v0": 1746, "cpu_time_v1": 149, "memory_v0": 11052, "memory_v1": 16752, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 91.47, "input": "n,m,k=list(map(int,input().split()))\n\nmod=10**9+7\n\nf=[1]\n\nfor i in range(2*10**5+7):f+=[f[-1]*(i+1)%mod]\n\ndef comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod\n\nans=0\n\nfor i in range(1,n):\n\n ans+=(i*(n-i)*m**2)*(comb(n*m-2,k-2))\n\n ans%=mod\n\nfor i in range(1,m):\n\n ans+=(i*(m-i)*n**2)*(comb(n*m-2,k-2))\n\n ans%=mod\n\nprint(ans)", "target": "n,m,k=list(map(int,input().split()))\n\n\n\nmod = 10**9+7\n\nf = [1]\n\nfor i in range(n*m):\n\n f += [f[-1]*(i+1) % mod]\n\ndef comb(a, b):\n\n return f[a]*pow(f[b], mod-2, mod)*pow(f[a-b], mod-2, mod) % mod\n\n\n\nans=0\n\nfor dist in range(1,n):\n\n c=n-dist\n\n p=(c*m*m)%mod\n\n ans+=p*dist\n\nfor dist in range(1,m):\n\n c=m-dist\n\n p=(c*n*n)%mod\n\n ans+=p*dist\n\nans%=mod\n\nprint((ans*comb(n*m-2,k-2)%mod))", "code_v0_loc": 13, "code_v1_loc": 20, "code_v0_num_chars": 340, "code_v1_num_chars": 379, "code_v0_no_empty_lines": "n, m, k = list(map(int, input().split()))\nmod = 10**9 + 7\nf = [1]\nfor i in range(2 * 10**5 + 7):\n f += [f[-1] * (i + 1) % mod]\n\n\ndef comb(a, b):\n return f[a] * pow(f[b], mod - 2, mod) * pow(f[a - b], mod - 2, mod) % mod\n\n\nans = 0\nfor i in range(1, n):\n ans += (i * (n - i) * m**2) * (comb(n * m - 2, k - 2))\n ans %= mod\nfor i in range(1, m):\n ans += (i * (m - i) * n**2) * (comb(n * m - 2, k - 2))\n ans %= mod\nprint(ans)\n", "code_v1_no_empty_lines": "n, m, k = list(map(int, input().split()))\nmod = 10**9 + 7\nf = [1]\nfor i in range(n * m):\n f += [f[-1] * (i + 1) % mod]\n\n\ndef comb(a, b):\n return f[a] * pow(f[b], mod - 2, mod) * pow(f[a - b], mod - 2, mod) % mod\n\n\nans = 0\nfor dist in range(1, n):\n c = n - dist\n p = (c * m * m) % mod\n ans += p * dist\nfor dist in range(1, m):\n c = m - dist\n p = (c * n * n) % mod\n ans += p * dist\nans %= mod\nprint((ans * comb(n * m - 2, k - 2) % mod))\n", "code_same": false, "relative_loc_diff_percent": 35.0, "diff": ["-for i in range(2 * 10**5 + 7):", "+for i in range(n * m):", "-for i in range(1, n):", "- ans += (i * (n - i) * m**2) * (comb(n * m - 2, k - 2))", "- ans %= mod", "-for i in range(1, m):", "- ans += (i * (m - i) * n**2) * (comb(n * m - 2, k - 2))", "- ans %= mod", "-print(ans)", "+for dist in range(1, n):", "+ c = n - dist", "+ p = (c * m * m) % mod", "+ ans += p * dist", "+for dist in range(1, m):", "+ c = m - dist", "+ p = (c * n * n) % mod", "+ ans += p * dist", "+ans %= mod", "+print((ans * comb(n * m - 2, k - 2) % mod))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.907170742, "measured_runtime_v1": 0.2339973826, "runtime_lift": 3.8768414063, "key": ["s481435936", "s241948863"]} {"user_id": "u562935282", "problem_id": "p03038", "language": "python", "submission_id_v0": "s653342727", "submission_id_v1": "s579349204", "cpu_time_v0": 535, "cpu_time_v1": 476, "memory_v0": 31964, "memory_v1": 42656, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 11.03, "input": "from heapq import heappop, heappush\n\n\n\nn, m = list(map(int, input().split()))\n\na = tuple(map(int, input().split()))\n\n\n\nhq = []\n\nfor aa in a:\n\n heappush(hq, (-aa, 1))\n\n\n\nfor _ in range(m):\n\n b, c = list(map(int, input().split()))\n\n heappush(hq, (-c, b))\n\n\n\nrest = n\n\nans = 0\n\nwhile rest > 0:\n\n num, cnt = heappop(hq)\n\n\n\n num *= (-1)\n\n use = min(rest, cnt)\n\n ans += use * num\n\n rest -= use\n\n\n\nprint(ans)\n", "target": "def main():\n\n from collections import Counter\n\n from operator import itemgetter\n\n\n\n import sys\n\n input = sys.stdin.readline\n\n\n\n N, M = list(map(int, input().split()))\n\n a = list(map(int, input().split()))\n\n\n\n ctr = Counter(a)\n\n for _ in range(M):\n\n b, c = list(map(int, input().split()))\n\n ctr[c] += b\n\n\n\n ans = 0\n\n rest = N\n\n for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):\n\n take = min(rest, count)\n\n ans += take * integer\n\n rest -= take\n\n if not rest:\n\n break\n\n\n\n print(ans)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n\n\n\n# import sys\n\n# input = sys.stdin.readline\n\n# \n\n# sys.setrecursionlimit(10 ** 7)\n\n# \n\n# (int(x)-1 for x in input().split())\n\n# rstrip()\n", "code_v0_loc": 24, "code_v1_loc": 37, "code_v0_num_chars": 414, "code_v1_num_chars": 760, "code_v0_no_empty_lines": "from heapq import heappop, heappush\n\nn, m = list(map(int, input().split()))\na = tuple(map(int, input().split()))\nhq = []\nfor aa in a:\n heappush(hq, (-aa, 1))\nfor _ in range(m):\n b, c = list(map(int, input().split()))\n heappush(hq, (-c, b))\nrest = n\nans = 0\nwhile rest > 0:\n num, cnt = heappop(hq)\n num *= -1\n use = min(rest, cnt)\n ans += use * num\n rest -= use\nprint(ans)\n", "code_v1_no_empty_lines": "def main():\n from collections import Counter\n from operator import itemgetter\n import sys\n\n input = sys.stdin.readline\n N, M = list(map(int, input().split()))\n a = list(map(int, input().split()))\n ctr = Counter(a)\n for _ in range(M):\n b, c = list(map(int, input().split()))\n ctr[c] += b\n ans = 0\n rest = N\n for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):\n take = min(rest, count)\n ans += take * integer\n rest -= take\n if not rest:\n break\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n# import sys\n# input = sys.stdin.readline\n#\n# sys.setrecursionlimit(10 ** 7)\n#\n# (int(x)-1 for x in input().split())\n# rstrip()\n", "code_same": false, "relative_loc_diff_percent": 35.1351351351, "diff": ["-from heapq import heappop, heappush", "+def main():", "+ from collections import Counter", "+ from operator import itemgetter", "+ import sys", "-n, m = list(map(int, input().split()))", "-a = tuple(map(int, input().split()))", "-hq = []", "-for aa in a:", "- heappush(hq, (-aa, 1))", "-for _ in range(m):", "- b, c = list(map(int, input().split()))", "- heappush(hq, (-c, b))", "-rest = n", "-ans = 0", "-while rest > 0:", "- num, cnt = heappop(hq)", "- num *= -1", "- use = min(rest, cnt)", "- ans += use * num", "- rest -= use", "-print(ans)", "+ input = sys.stdin.readline", "+ N, M = list(map(int, input().split()))", "+ a = list(map(int, input().split()))", "+ ctr = Counter(a)", "+ for _ in range(M):", "+ b, c = list(map(int, input().split()))", "+ ctr[c] += b", "+ ans = 0", "+ rest = N", "+ for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):", "+ take = min(rest, count)", "+ ans += take * integer", "+ rest -= take", "+ if not rest:", "+ break", "+ print(ans)", "+", "+", "+if __name__ == \"__main__\":", "+ main()", "+# import sys", "+# input = sys.stdin.readline", "+#", "+# sys.setrecursionlimit(10 ** 7)", "+#", "+# (int(x)-1 for x in input().split())", "+# rstrip()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3003652287, "measured_runtime_v1": 0.218658349, "runtime_lift": 1.3736737242, "key": ["s653342727", "s579349204"]} {"user_id": "u759934006", "problem_id": "p00174", "language": "python", "submission_id_v0": "s437122774", "submission_id_v1": "s723923476", "cpu_time_v0": 20, "cpu_time_v1": 10, "memory_v0": 4228, "memory_v1": 4232, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 50.0, "input": "while True:\n\n try:\n\n for i in range(3):\n\n line = input().strip()\n\n if line == '0':\n\n raise Exception\n\n\n\n a = b = 0\n\n for i, s in enumerate(line):\n\n if i != 0:\n\n if s == 'A':\n\n a += 1\n\n else:\n\n b += 1\n\n if a > b:\n\n a += 1\n\n else:\n\n b += 1\n\n print(a, b)\n\n\n\n except:\n\n break", "target": "while True:\n\n try:\n\n for i in range(3):\n\n line = input().strip()\n\n if line == '0':\n\n raise Exception\n\n\n\n if line[0] == 'A':\n\n a = -1\n\n b = 0\n\n else:\n\n a = 0\n\n b = -1\n\n for i, s in enumerate(line):\n\n if s == 'A':\n\n a += 1\n\n else:\n\n b += 1\n\n if a > b:\n\n a += 1\n\n else:\n\n b += 1\n\n print(a, b)\n\n\n\n except:\n\n break", "code_v0_loc": 22, "code_v1_loc": 26, "code_v0_num_chars": 515, "code_v1_num_chars": 593, "code_v0_no_empty_lines": "while True:\n try:\n for i in range(3):\n line = input().strip()\n if line == \"0\":\n raise Exception\n a = b = 0\n for i, s in enumerate(line):\n if i != 0:\n if s == \"A\":\n a += 1\n else:\n b += 1\n if a > b:\n a += 1\n else:\n b += 1\n print(a, b)\n except:\n break\n", "code_v1_no_empty_lines": "while True:\n try:\n for i in range(3):\n line = input().strip()\n if line == \"0\":\n raise Exception\n if line[0] == \"A\":\n a = -1\n b = 0\n else:\n a = 0\n b = -1\n for i, s in enumerate(line):\n if s == \"A\":\n a += 1\n else:\n b += 1\n if a > b:\n a += 1\n else:\n b += 1\n print(a, b)\n except:\n break\n", "code_same": false, "relative_loc_diff_percent": 15.3846153846, "diff": ["- a = b = 0", "+ if line[0] == \"A\":", "+ a = -1", "+ b = 0", "+ else:", "+ a = 0", "+ b = -1", "- if i != 0:", "- if s == \"A\":", "- a += 1", "- else:", "- b += 1", "+ if s == \"A\":", "+ a += 1", "+ else:", "+ b += 1"], "diff_only_import_comment": false, "measured_runtime_v0": 0.1803158569, "measured_runtime_v1": 0.0065688469, "runtime_lift": 27.4501534712, "key": ["s437122774", "s723923476"]} {"user_id": "u135454978", "problem_id": "p03371", "language": "python", "submission_id_v0": "s681762997", "submission_id_v1": "s948041496", "cpu_time_v0": 154, "cpu_time_v1": 17, "memory_v0": 3060, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 88.96, "input": "# AtCoder Beginner Contest 095 C - Half and Half\n\nimport sys\n\n\n\nA, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))\n\n\n\nans = A * X + B * Y\n\nfor z in range(2, 2 * 10 ** 5 + 1, 2):\n\n x = max(X - int(z / 2), 0)\n\n y = max(Y - int(z / 2), 0)\n\n\n\n price = A * x + B * y + C * z\n\n ans = min(price, ans)\n\n\n\nprint(ans)\n", "target": "# AtCoder Beginner Contest 095 C - Half and Half\n\nimport sys\n\n\n\nA, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))\n\n\n\n\"\"\"\n\nans = A * X + B * Y\n\nfor z in range(2, 2 * 10 ** 5 + 1, 2):\n\n x = max(X - int(z / 2), 0)\n\n y = max(Y - int(z / 2), 0)\n\n\n\n price = A * x + B * y + C * z\n\n ans = min(price, ans)\n\n\n\nprint(ans)\n\n\"\"\"\n\n\n\nprice1 = A * X + B * Y\n\nprice2 = C * 2 * X + B * max(Y - X, 0)\n\nprice3 = A * max(X - Y, 0) + C * 2 * Y\n\nprint((min(price1, price2, price3)))\n\n\n", "code_v0_loc": 14, "code_v1_loc": 22, "code_v0_num_chars": 332, "code_v1_num_chars": 486, "code_v0_no_empty_lines": "# AtCoder Beginner Contest 095 C - Half and Half\nimport sys\n\nA, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))\nans = A * X + B * Y\nfor z in range(2, 2 * 10**5 + 1, 2):\n x = max(X - int(z / 2), 0)\n y = max(Y - int(z / 2), 0)\n price = A * x + B * y + C * z\n ans = min(price, ans)\nprint(ans)\n", "code_v1_no_empty_lines": "# AtCoder Beginner Contest 095 C - Half and Half\nimport sys\n\nA, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split()))\n\"\"\"\nans = A * X + B * Y\nfor z in range(2, 2 * 10 ** 5 + 1, 2):\n x = max(X - int(z / 2), 0)\n y = max(Y - int(z / 2), 0)\n price = A * x + B * y + C * z\n ans = min(price, ans)\nprint(ans)\n\"\"\"\nprice1 = A * X + B * Y\nprice2 = C * 2 * X + B * max(Y - X, 0)\nprice3 = A * max(X - Y, 0) + C * 2 * Y\nprint((min(price1, price2, price3)))\n", "code_same": false, "relative_loc_diff_percent": 36.3636363636, "diff": ["+\"\"\"", "-for z in range(2, 2 * 10**5 + 1, 2):", "+for z in range(2, 2 * 10 ** 5 + 1, 2):", "+\"\"\"", "+price1 = A * X + B * Y", "+price2 = C * 2 * X + B * max(Y - X, 0)", "+price3 = A * max(X - Y, 0) + C * 2 * Y", "+print((min(price1, price2, price3)))"], "diff_only_import_comment": false, "measured_runtime_v0": 1.7125969741, "measured_runtime_v1": 0.2827094927, "runtime_lift": 6.0577979106, "key": ["s681762997", "s948041496"]} {"user_id": "u503228842", "problem_id": "p02555", "language": "python", "submission_id_v0": "s264986040", "submission_id_v1": "s936814116", "cpu_time_v0": 455, "cpu_time_v1": 29, "memory_v0": 9180, "memory_v1": 9188, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 93.63, "input": "n = int(input())\n\nm = 10**9 + 7\n\n# ans = [0] * (n + 1)\n\nans = [0] * 2200\n\nans[0] = 1\n\n# ans[3] = 1\n\n# ans[4] = 1\n\n# ans[5] = 1\n\nfor i in range(3, n + 1):\n\n for j in range(i - 2):\n\n ans[i] += ans[j]\n\n ans[i] %= m\n\nprint((ans[n]))\n\n# print(ans[:10])\n", "target": "n = int(input())\n\nm = 10**9 + 7\n\n# ans = [0] * (n + 1)\n\nans = [0] * 2200\n\nans[0] = 1\n\n# ans[3] = 1\n\n# ans[4] = 1\n\n# ans[5] = 1\n\nfor i in range(3, n + 1):\n\n ans[i] = ans[i - 1] + ans[i - 3]\n\n ans[i] %= m\n\n # for j in range(i - 2):\n\n # ans[i] += ans[j]\n\n # ans[i] %= m\n\nprint((ans[n]))\n\n# print(ans[:10])\n", "code_v0_loc": 14, "code_v1_loc": 16, "code_v0_num_chars": 263, "code_v1_num_chars": 324, "code_v0_no_empty_lines": "n = int(input())\nm = 10**9 + 7\n# ans = [0] * (n + 1)\nans = [0] * 2200\nans[0] = 1\n# ans[3] = 1\n# ans[4] = 1\n# ans[5] = 1\nfor i in range(3, n + 1):\n for j in range(i - 2):\n ans[i] += ans[j]\n ans[i] %= m\nprint((ans[n]))\n# print(ans[:10])\n", "code_v1_no_empty_lines": "n = int(input())\nm = 10**9 + 7\n# ans = [0] * (n + 1)\nans = [0] * 2200\nans[0] = 1\n# ans[3] = 1\n# ans[4] = 1\n# ans[5] = 1\nfor i in range(3, n + 1):\n ans[i] = ans[i - 1] + ans[i - 3]\n ans[i] %= m\n # for j in range(i - 2):\n # ans[i] += ans[j]\n # ans[i] %= m\nprint((ans[n]))\n# print(ans[:10])\n", "code_same": false, "relative_loc_diff_percent": 12.5, "diff": ["- for j in range(i - 2):", "- ans[i] += ans[j]", "- ans[i] %= m", "+ ans[i] = ans[i - 1] + ans[i - 3]", "+ ans[i] %= m", "+ # for j in range(i - 2):", "+ # ans[i] += ans[j]", "+ # ans[i] %= m"], "diff_only_import_comment": false, "measured_runtime_v0": 0.6218082716, "measured_runtime_v1": 0.188438025, "runtime_lift": 3.2998025299, "key": ["s264986040", "s936814116"]} {"user_id": "u057109575", "problem_id": "p02851", "language": "python", "submission_id_v0": "s203769987", "submission_id_v1": "s522861811", "cpu_time_v0": 293, "cpu_time_v1": 166, "memory_v0": 103224, "memory_v1": 144972, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 43.34, "input": "from collections import defaultdict\n\n\n\nN, K, *A = list(map(int, open(0).read().split()))\n\n\n\nS = [0] * (N + 1)\n\nfor i in range(N):\n\n S[i + 1] = S[i] + A[i]\n\n\n\nd = defaultdict(int)\n\nans = 0\n\nfor j in range(N + 1):\n\n v = (S[j] - j) % K\n\n ans += d[v]\n\n d[v] += 1\n\n if j >= K - 1:\n\n d[(S[j - K + 1] - (j - K + 1)) % K] -= 1\n\n \n\nprint(ans)\n", "target": "from collections import defaultdict\n\n\n\nN, K, *A = list(map(int, open(0).read().split()))\n\n\n\nx = [0] * (N + 1)\n\nfor i in range(N):\n\n x[i + 1] = x[i] + A[i]\n\n \n\ny = [(x[i] - i) % K for i in range(N + 1)]\n\n\n\nctr = defaultdict(int)\n\nans = 0\n\nfor j in range(N + 1):\n\n ans += ctr[y[j]]\n\n ctr[y[j]] += 1\n\n if j - K + 1 >= 0:\n\n ctr[y[j - K + 1]] -= 1\n\nprint(ans)\n", "code_v0_loc": 18, "code_v1_loc": 18, "code_v0_num_chars": 357, "code_v1_num_chars": 371, "code_v0_no_empty_lines": "from collections import defaultdict\n\nN, K, *A = list(map(int, open(0).read().split()))\nS = [0] * (N + 1)\nfor i in range(N):\n S[i + 1] = S[i] + A[i]\nd = defaultdict(int)\nans = 0\nfor j in range(N + 1):\n v = (S[j] - j) % K\n ans += d[v]\n d[v] += 1\n if j >= K - 1:\n d[(S[j - K + 1] - (j - K + 1)) % K] -= 1\nprint(ans)\n", "code_v1_no_empty_lines": "from collections import defaultdict\n\nN, K, *A = list(map(int, open(0).read().split()))\nx = [0] * (N + 1)\nfor i in range(N):\n x[i + 1] = x[i] + A[i]\ny = [(x[i] - i) % K for i in range(N + 1)]\nctr = defaultdict(int)\nans = 0\nfor j in range(N + 1):\n ans += ctr[y[j]]\n ctr[y[j]] += 1\n if j - K + 1 >= 0:\n ctr[y[j - K + 1]] -= 1\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["-S = [0] * (N + 1)", "+x = [0] * (N + 1)", "- S[i + 1] = S[i] + A[i]", "-d = defaultdict(int)", "+ x[i + 1] = x[i] + A[i]", "+y = [(x[i] - i) % K for i in range(N + 1)]", "+ctr = defaultdict(int)", "- v = (S[j] - j) % K", "- ans += d[v]", "- d[v] += 1", "- if j >= K - 1:", "- d[(S[j - K + 1] - (j - K + 1)) % K] -= 1", "+ ans += ctr[y[j]]", "+ ctr[y[j]] += 1", "+ if j - K + 1 >= 0:", "+ ctr[y[j - K + 1]] -= 1"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2436300242, "measured_runtime_v1": 0.1409657106, "runtime_lift": 1.7282928102, "key": ["s203769987", "s522861811"]} {"user_id": "u207097826", "problem_id": "p02792", "language": "python", "submission_id_v0": "s736173164", "submission_id_v1": "s628306332", "cpu_time_v0": 499, "cpu_time_v1": 86, "memory_v0": 3064, "memory_v1": 68180, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 82.77, "input": "import itertools\n\nN = int(input())\n\nNketa = len(str(N))\n\n\n\nrange_count = [[0 for j in range(10)]for i in range(10)]\n\n\n\n\n\nfor p in range(1,N+1):\n\n mae = int(str(p)[0])\n\n ato = int(str(p)[-1])\n\n range_count[mae][ato] += 1\n\n\n\n \n\n\n\ncount = 0\n\nfor j in range(1,N+1):\n\n a_mae = int(str(j)[0])\n\n a_ato = int(str(j)[-1])\n\n \n\n b_mae = a_ato\n\n b_ato = a_mae\n\n \n\n if b_mae == 0:\n\n continue\n\n else:\n\n count += range_count[b_mae][b_ato]\n\nprint(count)\n\n ", "target": "n = int(input())\n\n\n\nall_count = 0\n\noptions = [str(i) for i in range(10)]\n\n\n\nmaeato = [[0 for i in range(10)] for j in range(10)]\n\n\n\nfor i in range(n+1):\n\n checking = str(i)\n\n maeato[int(checking[0])][int(checking[-1])]+=1\n\nall_count = 0\n\nfor i in range(1,10):\n\n for j in range(1,10):\n\n for k in range(1,10):\n\n for p in range(1,10):\n\n if i == p and j == k:\n\n all_count+=maeato[i][j]*maeato[k][p]\n\nprint(all_count)", "code_v0_loc": 28, "code_v1_loc": 18, "code_v0_num_chars": 491, "code_v1_num_chars": 473, "code_v0_no_empty_lines": "import itertools\n\nN = int(input())\nNketa = len(str(N))\nrange_count = [[0 for j in range(10)] for i in range(10)]\nfor p in range(1, N + 1):\n mae = int(str(p)[0])\n ato = int(str(p)[-1])\n range_count[mae][ato] += 1\ncount = 0\nfor j in range(1, N + 1):\n a_mae = int(str(j)[0])\n a_ato = int(str(j)[-1])\n b_mae = a_ato\n b_ato = a_mae\n if b_mae == 0:\n continue\n else:\n count += range_count[b_mae][b_ato]\nprint(count)\n", "code_v1_no_empty_lines": "n = int(input())\nall_count = 0\noptions = [str(i) for i in range(10)]\nmaeato = [[0 for i in range(10)] for j in range(10)]\nfor i in range(n + 1):\n checking = str(i)\n maeato[int(checking[0])][int(checking[-1])] += 1\nall_count = 0\nfor i in range(1, 10):\n for j in range(1, 10):\n for k in range(1, 10):\n for p in range(1, 10):\n if i == p and j == k:\n all_count += maeato[i][j] * maeato[k][p]\nprint(all_count)\n", "code_same": false, "relative_loc_diff_percent": 35.7142857143, "diff": ["-import itertools", "-", "-N = int(input())", "-Nketa = len(str(N))", "-range_count = [[0 for j in range(10)] for i in range(10)]", "-for p in range(1, N + 1):", "- mae = int(str(p)[0])", "- ato = int(str(p)[-1])", "- range_count[mae][ato] += 1", "-count = 0", "-for j in range(1, N + 1):", "- a_mae = int(str(j)[0])", "- a_ato = int(str(j)[-1])", "- b_mae = a_ato", "- b_ato = a_mae", "- if b_mae == 0:", "- continue", "- else:", "- count += range_count[b_mae][b_ato]", "-print(count)", "+n = int(input())", "+all_count = 0", "+options = [str(i) for i in range(10)]", "+maeato = [[0 for i in range(10)] for j in range(10)]", "+for i in range(n + 1):", "+ checking = str(i)", "+ maeato[int(checking[0])][int(checking[-1])] += 1", "+all_count = 0", "+for i in range(1, 10):", "+ for j in range(1, 10):", "+ for k in range(1, 10):", "+ for p in range(1, 10):", "+ if i == p and j == k:", "+ all_count += maeato[i][j] * maeato[k][p]", "+print(all_count)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.5609512657, "measured_runtime_v1": 0.4347667047, "runtime_lift": 1.2902351069, "key": ["s736173164", "s628306332"]} {"user_id": "u457901067", "problem_id": "p02814", "language": "python", "submission_id_v0": "s285073705", "submission_id_v1": "s453740847", "cpu_time_v0": 523, "cpu_time_v1": 158, "memory_v0": 21860, "memory_v1": 97668, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 69.79, "input": "from math import gcd\n\nN, M = list(map(int, input().split()))\n\nA = list([int(x) for x in input().split()])\n\n\n\ncnt = [0 for _ in range(N)]\n\nfor i in range(N):\n\n a = A[i]\n\n while a%2 == 0:\n\n a = a // 2\n\n cnt[i] += 1\n\n\n\nif max(cnt) > min(cnt):\n\n print((0))\n\n exit(0)\n\nC = max(cnt)\n\n\n\nA = list([x // pow(2,C) for x in A])\n\ndef gcd(a,b):\n\n if a 0:\n\n a,b = b,a%b\n\n return b\n\n\n\ndef lcm(a,b):\n\n return a*b//gcd(a,b)\n\n\n\nx = A[0]\n\nfor a in A[1:]:\n\n x = lcm(x,a)\n\nx = x * pow(2,C-1)\n\n\n\nprint(((M // x + 1) // 2))", "target": "N, M = list(map(int, input().split()))\n\nA = list([int(x) for x in input().split()])\n\n\n\ncnt = [0 for _ in range(N)]\n\nfor i in range(N):\n\n a = A[i]\n\n while a%2 == 0:\n\n a = a // 2\n\n cnt[i] += 1\n\n\n\nif max(cnt) > min(cnt):\n\n print((0))\n\n exit(0)\n\nC = max(cnt)\n\n\n\nA = list([x // pow(2,C) for x in A])\n\ndef gcd(a,b):\n\n if a 0:\n\n a,b = b,a%b\n\n return b\n\n\n\ndef lcm(a,b):\n\n return a*b//gcd(a,b)\n\n\n\nx = A[0]\n\nfor a in A[1:]:\n\n x = lcm(x,a)\n\nx = x * pow(2,C-1)\n\n\n\nprint(((M // x + 1) // 2))", "code_v0_loc": 33, "code_v1_loc": 32, "code_v0_num_chars": 560, "code_v1_num_chars": 533, "code_v0_no_empty_lines": "from math import gcd\n\nN, M = list(map(int, input().split()))\nA = list([int(x) for x in input().split()])\ncnt = [0 for _ in range(N)]\nfor i in range(N):\n a = A[i]\n while a % 2 == 0:\n a = a // 2\n cnt[i] += 1\nif max(cnt) > min(cnt):\n print((0))\n exit(0)\nC = max(cnt)\nA = list([x // pow(2, C) for x in A])\n\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b > 0:\n a, b = b, a % b\n return b\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\nx = A[0]\nfor a in A[1:]:\n x = lcm(x, a)\nx = x * pow(2, C - 1)\nprint(((M // x + 1) // 2))\n", "code_v1_no_empty_lines": "N, M = list(map(int, input().split()))\nA = list([int(x) for x in input().split()])\ncnt = [0 for _ in range(N)]\nfor i in range(N):\n a = A[i]\n while a % 2 == 0:\n a = a // 2\n cnt[i] += 1\nif max(cnt) > min(cnt):\n print((0))\n exit(0)\nC = max(cnt)\nA = list([x // pow(2, C) for x in A])\n\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b > 0:\n a, b = b, a % b\n return b\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\nx = A[0]\nfor a in A[1:]:\n x = lcm(x, a)\nx = x * pow(2, C - 1)\nprint(((M // x + 1) // 2))\n", "code_same": false, "relative_loc_diff_percent": 3.0303030303, "diff": ["-from math import gcd", "-"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2484916873, "measured_runtime_v1": 0.192324806, "runtime_lift": 1.2920417937, "key": ["s285073705", "s453740847"]} {"user_id": "u440566786", "problem_id": "p03558", "language": "python", "submission_id_v0": "s333680155", "submission_id_v1": "s106353030", "cpu_time_v0": 260, "cpu_time_v1": 131, "memory_v0": 62004, "memory_v1": 79416, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 49.62, "input": "import sys\n\nsys.setrecursionlimit(2147483647)\n\nINF=float(\"inf\")\n\nMOD=10**9+7\n\ninput=lambda :sys.stdin.readline().rstrip()\n\n\n\nfrom collections import deque\n\ndef resolve():\n\n k=int(input())\n\n E=[[] for _ in range(k)]\n\n for i in range(k):\n\n E[i].append(((i+1)%k,1))\n\n E[i].append(((10*i)%k,0))\n\n\n\n # 0-1 BFS\n\n dist=[INF]*k\n\n dist[1]=0\n\n Q=deque([1])\n\n while(Q):\n\n v=Q.popleft()\n\n for nv,w in E[v]:\n\n if(dist[nv]<=dist[v]+w): continue\n\n dist[nv]=dist[v]+w\n\n if(w==0): Q.appendleft(nv)\n\n else: Q.append(nv)\n\n print((dist[0]+1))\n\nresolve()", "target": "import sys\n\nINF = 1 << 60\n\nMOD = 10**9 + 7 # 998244353\n\nsys.setrecursionlimit(2147483647)\n\ninput = lambda:sys.stdin.readline().rstrip()\n\nfrom collections import deque\n\ndef resolve():\n\n k = int(input())\n\n dist = [INF] * k\n\n dist[1] = 1\n\n queue = deque([1])\n\n\n\n while queue:\n\n v = queue.pop()\n\n if dist[10 * v % k] > dist[v]:\n\n dist[10 * v % k] = dist[v]\n\n queue.appendleft(10 * v % k)\n\n if dist[(v + 1) % k] > dist[v] + 1:\n\n dist[(v + 1) % k] = dist[v] + 1\n\n queue.append((v + 1) % k)\n\n\n\n print((dist[0]))\n\nresolve()", "code_v0_loc": 27, "code_v1_loc": 23, "code_v0_num_chars": 630, "code_v1_num_chars": 596, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(2147483647)\nINF = float(\"inf\")\nMOD = 10**9 + 7\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque\n\n\ndef resolve():\n k = int(input())\n E = [[] for _ in range(k)]\n for i in range(k):\n E[i].append(((i + 1) % k, 1))\n E[i].append(((10 * i) % k, 0))\n # 0-1 BFS\n dist = [INF] * k\n dist[1] = 0\n Q = deque([1])\n while Q:\n v = Q.popleft()\n for nv, w in E[v]:\n if dist[nv] <= dist[v] + w:\n continue\n dist[nv] = dist[v] + w\n if w == 0:\n Q.appendleft(nv)\n else:\n Q.append(nv)\n print((dist[0] + 1))\n\n\nresolve()\n", "code_v1_no_empty_lines": "import sys\n\nINF = 1 << 60\nMOD = 10**9 + 7 # 998244353\nsys.setrecursionlimit(2147483647)\ninput = lambda: sys.stdin.readline().rstrip()\nfrom collections import deque\n\n\ndef resolve():\n k = int(input())\n dist = [INF] * k\n dist[1] = 1\n queue = deque([1])\n while queue:\n v = queue.pop()\n if dist[10 * v % k] > dist[v]:\n dist[10 * v % k] = dist[v]\n queue.appendleft(10 * v % k)\n if dist[(v + 1) % k] > dist[v] + 1:\n dist[(v + 1) % k] = dist[v] + 1\n queue.append((v + 1) % k)\n print((dist[0]))\n\n\nresolve()\n", "code_same": false, "relative_loc_diff_percent": 14.8148148148, "diff": ["+INF = 1 << 60", "+MOD = 10**9 + 7 # 998244353", "-INF = float(\"inf\")", "-MOD = 10**9 + 7", "- E = [[] for _ in range(k)]", "- for i in range(k):", "- E[i].append(((i + 1) % k, 1))", "- E[i].append(((10 * i) % k, 0))", "- # 0-1 BFS", "- dist[1] = 0", "- Q = deque([1])", "- while Q:", "- v = Q.popleft()", "- for nv, w in E[v]:", "- if dist[nv] <= dist[v] + w:", "- continue", "- dist[nv] = dist[v] + w", "- if w == 0:", "- Q.appendleft(nv)", "- else:", "- Q.append(nv)", "- print((dist[0] + 1))", "+ dist[1] = 1", "+ queue = deque([1])", "+ while queue:", "+ v = queue.pop()", "+ if dist[10 * v % k] > dist[v]:", "+ dist[10 * v % k] = dist[v]", "+ queue.appendleft(10 * v % k)", "+ if dist[(v + 1) % k] > dist[v] + 1:", "+ dist[(v + 1) % k] = dist[v] + 1", "+ queue.append((v + 1) % k)", "+ print((dist[0]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.412358222, "measured_runtime_v1": 0.3278088195, "runtime_lift": 1.2579229033, "key": ["s333680155", "s106353030"]} {"user_id": "u761320129", "problem_id": "p03839", "language": "python", "submission_id_v0": "s934844992", "submission_id_v1": "s135860240", "cpu_time_v0": 205, "cpu_time_v1": 174, "memory_v0": 17404, "memory_v1": 17532, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 15.12, "input": "N,K = list(map(int,input().split()))\n\nsrc = list(map(int,input().split()))\n\n\n\ncums = [0]\n\ncump = [0]\n\nfor a in src:\n\n cums.append(cums[-1] + a)\n\n cump.append(cump[-1] + max(0,a))\n\n\n\nans = 0\n\nfor i in range(N-K+1):\n\n tmp = cump[i]\n\n tmp += max(0, cums[i+K] - cums[i])\n\n tmp += cump[N] - cump[i+K]\n\n ans = max(tmp, ans)\n\nprint(ans)\n", "target": "N,K = list(map(int,input().split()))\n\nA = list(map(int,input().split()))\n\n\n\ncums = [0]\n\ncums_p = [0]\n\nfor a in A:\n\n cums.append(cums[-1] + a)\n\n cums_p.append(cums_p[-1] + max(0,a))\n\n\n\nans = -float('inf')\n\nfor l in range(N-K+1):\n\n free = cums_p[l] + cums_p[-1] - cums_p[l+K]\n\n cont = cums[l+K] - cums[l]\n\n ans = max(ans, free, free+cont)\n\nprint(ans)", "code_v0_loc": 16, "code_v1_loc": 15, "code_v0_num_chars": 342, "code_v1_num_chars": 357, "code_v0_no_empty_lines": "N, K = list(map(int, input().split()))\nsrc = list(map(int, input().split()))\ncums = [0]\ncump = [0]\nfor a in src:\n cums.append(cums[-1] + a)\n cump.append(cump[-1] + max(0, a))\nans = 0\nfor i in range(N - K + 1):\n tmp = cump[i]\n tmp += max(0, cums[i + K] - cums[i])\n tmp += cump[N] - cump[i + K]\n ans = max(tmp, ans)\nprint(ans)\n", "code_v1_no_empty_lines": "N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\ncums = [0]\ncums_p = [0]\nfor a in A:\n cums.append(cums[-1] + a)\n cums_p.append(cums_p[-1] + max(0, a))\nans = -float(\"inf\")\nfor l in range(N - K + 1):\n free = cums_p[l] + cums_p[-1] - cums_p[l + K]\n cont = cums[l + K] - cums[l]\n ans = max(ans, free, free + cont)\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 6.25, "diff": ["-src = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "-cump = [0]", "-for a in src:", "+cums_p = [0]", "+for a in A:", "- cump.append(cump[-1] + max(0, a))", "-ans = 0", "-for i in range(N - K + 1):", "- tmp = cump[i]", "- tmp += max(0, cums[i + K] - cums[i])", "- tmp += cump[N] - cump[i + K]", "- ans = max(tmp, ans)", "+ cums_p.append(cums_p[-1] + max(0, a))", "+ans = -float(\"inf\")", "+for l in range(N - K + 1):", "+ free = cums_p[l] + cums_p[-1] - cums_p[l + K]", "+ cont = cums[l + K] - cums[l]", "+ ans = max(ans, free, free + cont)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3907449563, "measured_runtime_v1": 0.3033102551, "runtime_lift": 1.2882681998, "key": ["s934844992", "s135860240"]} {"user_id": "u766684188", "problem_id": "p02821", "language": "python", "submission_id_v0": "s756543404", "submission_id_v1": "s283463453", "cpu_time_v0": 1684, "cpu_time_v1": 1054, "memory_v0": 58816, "memory_v1": 60104, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 37.41, "input": "#E\n\nfrom itertools import accumulate\n\nfrom bisect import bisect_left\n\ndef main():\n\n n,m=list(map(int,input().split()))\n\n A=list(map(int,input().split()))\n\n A.sort()\n\n \n\n def count(k):\n\n cnt=0\n\n for a in A:\n\n cnt+=bisect_left(A,k-a)\n\n return cnt\n\n \n\n ok=0\n\n ng=10**10+1\n\n while ng-ok>1:\n\n mid=(ok+ng)//2\n\n if count(mid)1:\n\n mid=(ok+ng)//2\n\n if count(mid) 1:\n mid = (ok + ng) // 2\n if count(mid) < n**2 - m:\n ok = mid\n else:\n ng = mid\n border = ok\n k = n**2 - count(border)\n Acc = [0] + list(accumulate(A))\n s = Acc[-1]\n ans = 0\n for a in A:\n idx = bisect_left(A, border - a)\n ans += a * (n - idx) + (s - Acc[idx])\n ans -= border * (k - m)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "from itertools import accumulate\nfrom bisect import bisect_left\n\n\ndef main():\n n, m = list(map(int, input().split()))\n A = list(map(int, input().split()))\n A.sort()\n\n def count(k):\n cnt = 0\n for a in A:\n cnt += bisect_left(A, k - a)\n return cnt\n\n ok = 0\n ng = 2 * 10**5 + 1\n while ng - ok > 1:\n mid = (ok + ng) // 2\n if count(mid) < n**2 - m:\n ok = mid\n else:\n ng = mid\n border = ok\n k = n**2 - count(border)\n Acc = [0] + list(accumulate(A))\n s = Acc[-1]\n ans = 0\n for a in A:\n idx = bisect_left(A, border - a)\n ans += a * (n - idx) + (s - Acc[idx])\n ans -= border * (k - m)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 2.7777777778, "diff": ["-# E", "- ng = 10**10 + 1", "+ ng = 2 * 10**5 + 1"], "diff_only_import_comment": false, "measured_runtime_v0": 0.329581742, "measured_runtime_v1": 0.2004272747, "runtime_lift": 1.6443956668, "key": ["s756543404", "s283463453"]} {"user_id": "u738898077", "problem_id": "p03634", "language": "python", "submission_id_v0": "s144783413", "submission_id_v1": "s080655040", "cpu_time_v0": 845, "cpu_time_v1": 724, "memory_v0": 48964, "memory_v1": 48916, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 14.32, "input": "import sys\n\ninput = sys.stdin.readline\n\nn = int(input())\n\nv = [[0]+[]*(n+1) for i in range(n+1)]\n\nfor i in range(n-1):\n\n a,b,c = list(map(int,input().split()))\n\n v[a].append([b,c])\n\n v[b].append([a,c])\n\n\n\nq,k = list(map(int,input().split()))\n\nl = [k]\n\nwhile l:\n\n now = l.pop()\n\n for i in v[now][1:]:\n\n if v[i[0]][0] == 0:\n\n v[i[0]][0] = i[1]+v[now][0]\n\n l.append(i[0])\n\n\n\nfor i in range(q):\n\n x,y = list(map(int,input().split()))\n\n print((v[x][0]+v[y][0]))", "target": "import sys\n\ndef main():\n\n input = sys.stdin.readline\n\n n = int(input())\n\n v = [[0]+[]*(n+1) for i in range(n+1)]\n\n for i in range(n-1):\n\n a,b,c = list(map(int,input().split()))\n\n v[a].append([b,c])\n\n v[b].append([a,c])\n\n\n\n q,k = list(map(int,input().split()))\n\n l = [k]\n\n while l:\n\n now = l.pop()\n\n for i in v[now][1:]:\n\n if v[i[0]][0] == 0:\n\n v[i[0]][0] = i[1]+v[now][0]\n\n l.append(i[0])\n\n\n\n for i in range(q):\n\n x,y = list(map(int,input().split()))\n\n print((v[x][0]+v[y][0]))\n\n\n\nif __name__ == '__main__':\n\n main()", "code_v0_loc": 21, "code_v1_loc": 25, "code_v0_num_chars": 486, "code_v1_num_chars": 613, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nn = int(input())\nv = [[0] + [] * (n + 1) for i in range(n + 1)]\nfor i in range(n - 1):\n a, b, c = list(map(int, input().split()))\n v[a].append([b, c])\n v[b].append([a, c])\nq, k = list(map(int, input().split()))\nl = [k]\nwhile l:\n now = l.pop()\n for i in v[now][1:]:\n if v[i[0]][0] == 0:\n v[i[0]][0] = i[1] + v[now][0]\n l.append(i[0])\nfor i in range(q):\n x, y = list(map(int, input().split()))\n print((v[x][0] + v[y][0]))\n", "code_v1_no_empty_lines": "import sys\n\n\ndef main():\n input = sys.stdin.readline\n n = int(input())\n v = [[0] + [] * (n + 1) for i in range(n + 1)]\n for i in range(n - 1):\n a, b, c = list(map(int, input().split()))\n v[a].append([b, c])\n v[b].append([a, c])\n q, k = list(map(int, input().split()))\n l = [k]\n while l:\n now = l.pop()\n for i in v[now][1:]:\n if v[i[0]][0] == 0:\n v[i[0]][0] = i[1] + v[now][0]\n l.append(i[0])\n for i in range(q):\n x, y = list(map(int, input().split()))\n print((v[x][0] + v[y][0]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 16.0, "diff": ["-input = sys.stdin.readline", "-n = int(input())", "-v = [[0] + [] * (n + 1) for i in range(n + 1)]", "-for i in range(n - 1):", "- a, b, c = list(map(int, input().split()))", "- v[a].append([b, c])", "- v[b].append([a, c])", "-q, k = list(map(int, input().split()))", "-l = [k]", "-while l:", "- now = l.pop()", "- for i in v[now][1:]:", "- if v[i[0]][0] == 0:", "- v[i[0]][0] = i[1] + v[now][0]", "- l.append(i[0])", "-for i in range(q):", "- x, y = list(map(int, input().split()))", "- print((v[x][0] + v[y][0]))", "+", "+def main():", "+ input = sys.stdin.readline", "+ n = int(input())", "+ v = [[0] + [] * (n + 1) for i in range(n + 1)]", "+ for i in range(n - 1):", "+ a, b, c = list(map(int, input().split()))", "+ v[a].append([b, c])", "+ v[b].append([a, c])", "+ q, k = list(map(int, input().split()))", "+ l = [k]", "+ while l:", "+ now = l.pop()", "+ for i in v[now][1:]:", "+ if v[i[0]][0] == 0:", "+ v[i[0]][0] = i[1] + v[now][0]", "+ l.append(i[0])", "+ for i in range(q):", "+ x, y = list(map(int, input().split()))", "+ print((v[x][0] + v[y][0]))", "+", "+", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3066135428, "measured_runtime_v1": 0.2174853971, "runtime_lift": 1.4098120925, "key": ["s144783413", "s080655040"]} {"user_id": "u628707847", "problem_id": "p02748", "language": "python", "submission_id_v0": "s393648468", "submission_id_v1": "s394235092", "cpu_time_v0": 533, "cpu_time_v1": 471, "memory_v0": 30260, "memory_v1": 21668, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 11.63, "input": "a, b, m = list(map(int,input().split()))\n\ndr = list(map(int,input().split()))\n\nwa = list(map(int,input().split()))\n\nxyc = [list(map(int,input().split())) for i in range(m)]\n\nlow = 200001\n\n\n\nfor i in range(m):\n\n f = xyc[i][0] - 1\n\n d = xyc[i][1] - 1\n\n if low >= dr[f]+wa[d]-xyc[i][2]:\n\n low = dr[f]+wa[d]-xyc[i][2]\n\n\n\ndr.sort()\n\nwa.sort()\n\n\n\nif low >= (dr[0] + wa[0]):\n\n print((dr[0] + wa[0]))\n\nelse:\n\n print(low)", "target": "a, b, m = list(map(int,input().split()))\n\nal = list(map(int,input().split()))\n\nbl = list(map(int,input().split()))\n\nlow = min(al)+min(bl)\n\nx = [0] * m\n\ny = [0] * m\n\nc = [0] * m\n\n\n\nfor i in range(m):\n\n x[i],y[i],c[i] = list(map(int, input().split()))\n\n x[i] -= 1\n\n y[i] -= 1\n\n \n\nfor i in range(m):\n\n low = min(low,al[x[i]]+bl[y[i]]-c[i])\n\n\n\nprint(low)", "code_v0_loc": 19, "code_v1_loc": 17, "code_v0_num_chars": 424, "code_v1_num_chars": 353, "code_v0_no_empty_lines": "a, b, m = list(map(int, input().split()))\ndr = list(map(int, input().split()))\nwa = list(map(int, input().split()))\nxyc = [list(map(int, input().split())) for i in range(m)]\nlow = 200001\nfor i in range(m):\n f = xyc[i][0] - 1\n d = xyc[i][1] - 1\n if low >= dr[f] + wa[d] - xyc[i][2]:\n low = dr[f] + wa[d] - xyc[i][2]\ndr.sort()\nwa.sort()\nif low >= (dr[0] + wa[0]):\n print((dr[0] + wa[0]))\nelse:\n print(low)\n", "code_v1_no_empty_lines": "a, b, m = list(map(int, input().split()))\nal = list(map(int, input().split()))\nbl = list(map(int, input().split()))\nlow = min(al) + min(bl)\nx = [0] * m\ny = [0] * m\nc = [0] * m\nfor i in range(m):\n x[i], y[i], c[i] = list(map(int, input().split()))\n x[i] -= 1\n y[i] -= 1\nfor i in range(m):\n low = min(low, al[x[i]] + bl[y[i]] - c[i])\nprint(low)\n", "code_same": false, "relative_loc_diff_percent": 10.5263157895, "diff": ["-dr = list(map(int, input().split()))", "-wa = list(map(int, input().split()))", "-xyc = [list(map(int, input().split())) for i in range(m)]", "-low = 200001", "+al = list(map(int, input().split()))", "+bl = list(map(int, input().split()))", "+low = min(al) + min(bl)", "+x = [0] * m", "+y = [0] * m", "+c = [0] * m", "- f = xyc[i][0] - 1", "- d = xyc[i][1] - 1", "- if low >= dr[f] + wa[d] - xyc[i][2]:", "- low = dr[f] + wa[d] - xyc[i][2]", "-dr.sort()", "-wa.sort()", "-if low >= (dr[0] + wa[0]):", "- print((dr[0] + wa[0]))", "-else:", "- print(low)", "+ x[i], y[i], c[i] = list(map(int, input().split()))", "+ x[i] -= 1", "+ y[i] -= 1", "+for i in range(m):", "+ low = min(low, al[x[i]] + bl[y[i]] - c[i])", "+print(low)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2055197518, "measured_runtime_v1": 0.0063774352, "runtime_lift": 32.2260822388, "key": ["s393648468", "s394235092"]} {"user_id": "u281303342", "problem_id": "p03828", "language": "python", "submission_id_v0": "s909168869", "submission_id_v1": "s458659043", "cpu_time_v0": 68, "cpu_time_v1": 27, "memory_v0": 3316, "memory_v1": 3316, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 60.29, "input": "from collections import Counter\n\nN = int(input())\n\ndiv = []\n\nfor i in range(2,N+1):\n\n while i != 1:\n\n for d in range(2,i+1):\n\n while i%d==0:\n\n i = i//d\n\n div.append(d)\n\nC = Counter(div).most_common()\n\nAns = 1\n\nfor k,v in C:\n\n Ans = Ans*(v+1) % (10**9+7)\n\n\n\nprint(Ans)\n", "target": "from collections import defaultdict\n\nN = int(input())\n\n\n\nF = [True]*(N+1)\n\nF[0]=F[1]=False\n\nP = []\n\n\n\nfor i in range(2,N+1):\n\n if F[i]==True:\n\n P.append(i)\n\n for j in range(i*2,N+1,i):\n\n F[j]=False\n\n\n\ndic = defaultdict(int)\n\nfor i in range(2,N+1):\n\n for p in P:\n\n while i%p==0:\n\n dic[p] += 1\n\n i = i//p\n\n if i==1:\n\n break\n\n\n\nans = 1\n\nmodulo = 10**9+7\n\nfor v in list(dic.values()):\n\n ans *= (v+1)\n\n ans %= modulo\n\n\n\nprint(ans)", "code_v0_loc": 15, "code_v1_loc": 29, "code_v0_num_chars": 322, "code_v1_num_chars": 503, "code_v0_no_empty_lines": "from collections import Counter\n\nN = int(input())\ndiv = []\nfor i in range(2, N + 1):\n while i != 1:\n for d in range(2, i + 1):\n while i % d == 0:\n i = i // d\n div.append(d)\nC = Counter(div).most_common()\nAns = 1\nfor k, v in C:\n Ans = Ans * (v + 1) % (10**9 + 7)\nprint(Ans)\n", "code_v1_no_empty_lines": "from collections import defaultdict\n\nN = int(input())\nF = [True] * (N + 1)\nF[0] = F[1] = False\nP = []\nfor i in range(2, N + 1):\n if F[i] == True:\n P.append(i)\n for j in range(i * 2, N + 1, i):\n F[j] = False\ndic = defaultdict(int)\nfor i in range(2, N + 1):\n for p in P:\n while i % p == 0:\n dic[p] += 1\n i = i // p\n if i == 1:\n break\nans = 1\nmodulo = 10**9 + 7\nfor v in list(dic.values()):\n ans *= v + 1\n ans %= modulo\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 48.275862069, "diff": ["-from collections import Counter", "+from collections import defaultdict", "-div = []", "+F = [True] * (N + 1)", "+F[0] = F[1] = False", "+P = []", "- while i != 1:", "- for d in range(2, i + 1):", "- while i % d == 0:", "- i = i // d", "- div.append(d)", "-C = Counter(div).most_common()", "-Ans = 1", "-for k, v in C:", "- Ans = Ans * (v + 1) % (10**9 + 7)", "-print(Ans)", "+ if F[i] == True:", "+ P.append(i)", "+ for j in range(i * 2, N + 1, i):", "+ F[j] = False", "+dic = defaultdict(int)", "+for i in range(2, N + 1):", "+ for p in P:", "+ while i % p == 0:", "+ dic[p] += 1", "+ i = i // p", "+ if i == 1:", "+ break", "+ans = 1", "+modulo = 10**9 + 7", "+for v in list(dic.values()):", "+ ans *= v + 1", "+ ans %= modulo", "+print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3373793194, "measured_runtime_v1": 0.2469508071, "runtime_lift": 1.3661802664, "key": ["s909168869", "s458659043"]} {"user_id": "u556358547", "problem_id": "p03416", "language": "python", "submission_id_v0": "s971943319", "submission_id_v1": "s985131399", "cpu_time_v0": 94, "cpu_time_v1": 70, "memory_v0": 73744, "memory_v1": 64480, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.53, "input": "# vim: fileencoding=utf-8\n\n\n\n\n\ndef main():\n\n a, b = list(map(int, input().split()))\n\n c = 0\n\n for i in range(a, b + 1):\n\n s = str(i)\n\n r = \"\".join(reversed(list(s)))\n\n if s == r:\n\n c += 1\n\n print(c)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "# vim: fileencoding=utf-8\n\n\n\n\n\ndef main():\n\n a, b = list(map(int, input().split()))\n\n c = 0\n\n for i in range(a, b + 1):\n\n # s = str(i)\n\n # r = \"\".join(reversed(list(s)))\n\n # if s == r:\n\n # c += 1\n\n if (i % 10) == (i // 10000 % 10) and (i // 10 % 10) == (i // 1000 % 10):\n\n c += 1\n\n print(c)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "code_v0_loc": 16, "code_v1_loc": 18, "code_v0_num_chars": 281, "code_v1_num_chars": 407, "code_v0_no_empty_lines": "# vim: fileencoding=utf-8\ndef main():\n a, b = list(map(int, input().split()))\n c = 0\n for i in range(a, b + 1):\n s = str(i)\n r = \"\".join(reversed(list(s)))\n if s == r:\n c += 1\n print(c)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "# vim: fileencoding=utf-8\ndef main():\n a, b = list(map(int, input().split()))\n c = 0\n for i in range(a, b + 1):\n # s = str(i)\n # r = \"\".join(reversed(list(s)))\n # if s == r:\n # c += 1\n if (i % 10) == (i // 10000 % 10) and (i // 10 % 10) == (i // 1000 % 10):\n c += 1\n print(c)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 11.1111111111, "diff": ["- s = str(i)", "- r = \"\".join(reversed(list(s)))", "- if s == r:", "+ # s = str(i)", "+ # r = \"\".join(reversed(list(s)))", "+ # if s == r:", "+ # c += 1", "+ if (i % 10) == (i // 10000 % 10) and (i // 10 % 10) == (i // 1000 % 10):"], "diff_only_import_comment": false, "measured_runtime_v0": 0.319033144, "measured_runtime_v1": 0.2127196875, "runtime_lift": 1.4997819327, "key": ["s971943319", "s985131399"]} {"user_id": "u764401543", "problem_id": "p03371", "language": "python", "submission_id_v0": "s157366337", "submission_id_v1": "s208344914", "cpu_time_v0": 114, "cpu_time_v1": 17, "memory_v0": 2940, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 85.09, "input": "A, B, C, X, Y = list(map(int, input().split()))\n\n\n\nans = float('inf')\n\n\n\nfor i in range(10 ** 5 + 1):\n\n ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)\n\nprint(ans)", "target": "A, B, C, X, Y = list(map(int, input().split()))\n\n\n\n# ans = float('inf')\n\n\n\n# for i in range(10 ** 5 + 1):\n\n# ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)\n\n# print(ans)\n\n\n\nmin_xy = min(X, Y)\n\nmax_xy = max(X, Y)\n\nans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)\n\nans2 = A * X + B * Y\n\nans3 = 2 * C * max_xy\n\nprint((min(ans1, ans2, ans3)))", "code_v0_loc": 7, "code_v1_loc": 14, "code_v0_num_chars": 178, "code_v1_num_chars": 364, "code_v0_no_empty_lines": "A, B, C, X, Y = list(map(int, input().split()))\nans = float(\"inf\")\nfor i in range(10**5 + 1):\n ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)\nprint(ans)\n", "code_v1_no_empty_lines": "A, B, C, X, Y = list(map(int, input().split()))\n# ans = float('inf')\n# for i in range(10 ** 5 + 1):\n# ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)\n# print(ans)\nmin_xy = min(X, Y)\nmax_xy = max(X, Y)\nans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)\nans2 = A * X + B * Y\nans3 = 2 * C * max_xy\nprint((min(ans1, ans2, ans3)))\n", "code_same": false, "relative_loc_diff_percent": 50.0, "diff": ["-ans = float(\"inf\")", "-for i in range(10**5 + 1):", "- ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)", "-print(ans)", "+# ans = float('inf')", "+# for i in range(10 ** 5 + 1):", "+# ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i)", "+# print(ans)", "+min_xy = min(X, Y)", "+max_xy = max(X, Y)", "+ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)", "+ans2 = A * X + B * Y", "+ans3 = 2 * C * max_xy", "+print((min(ans1, ans2, ans3)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.8766576855, "measured_runtime_v1": 0.1948450158, "runtime_lift": 4.4992564066, "key": ["s157366337", "s208344914"]} {"user_id": "u025501820", "problem_id": "p02792", "language": "python", "submission_id_v0": "s746150122", "submission_id_v1": "s989284284", "cpu_time_v0": 318, "cpu_time_v1": 169, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 46.86, "input": "N = int(input())\n\ncount = [[0 for _ in range(9)] for _ in range(9)]\n\nfor i in range(1, N + 1):\n\n if str(i)[0] != \"0\" and str(i)[-1] != \"0\":\n\n count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1\n\nans = 0\n\nfor i in range(0, 9):\n\n for k in range(0, 9):\n\n ans += count[i][k] * count[k][i]\n\nprint(ans)", "target": "N = int(input())\n\nnums = [0 for i in range(100)]\n\nfor i in range(1, N + 1):\n\n i = str(i)\n\n nums[int(i[0] + i[-1])] += 1\n\nans = 0\n\nfor i in range(1, 10):\n\n for j in range(i, 10):\n\n i = str(i)\n\n j = str(j)\n\n if i != j:\n\n ans += nums[int(i + j)] * nums[int(j + i)] * 2\n\n else:\n\n n = nums[int(i + j)]\n\n ans += n * (n - 1)\n\n ans += n\n\nprint(ans)", "code_v0_loc": 10, "code_v1_loc": 17, "code_v0_num_chars": 316, "code_v1_num_chars": 421, "code_v0_no_empty_lines": "N = int(input())\ncount = [[0 for _ in range(9)] for _ in range(9)]\nfor i in range(1, N + 1):\n if str(i)[0] != \"0\" and str(i)[-1] != \"0\":\n count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1\nans = 0\nfor i in range(0, 9):\n for k in range(0, 9):\n ans += count[i][k] * count[k][i]\nprint(ans)\n", "code_v1_no_empty_lines": "N = int(input())\nnums = [0 for i in range(100)]\nfor i in range(1, N + 1):\n i = str(i)\n nums[int(i[0] + i[-1])] += 1\nans = 0\nfor i in range(1, 10):\n for j in range(i, 10):\n i = str(i)\n j = str(j)\n if i != j:\n ans += nums[int(i + j)] * nums[int(j + i)] * 2\n else:\n n = nums[int(i + j)]\n ans += n * (n - 1)\n ans += n\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 41.1764705882, "diff": ["-count = [[0 for _ in range(9)] for _ in range(9)]", "+nums = [0 for i in range(100)]", "- if str(i)[0] != \"0\" and str(i)[-1] != \"0\":", "- count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1", "+ i = str(i)", "+ nums[int(i[0] + i[-1])] += 1", "-for i in range(0, 9):", "- for k in range(0, 9):", "- ans += count[i][k] * count[k][i]", "+for i in range(1, 10):", "+ for j in range(i, 10):", "+ i = str(i)", "+ j = str(j)", "+ if i != j:", "+ ans += nums[int(i + j)] * nums[int(j + i)] * 2", "+ else:", "+ n = nums[int(i + j)]", "+ ans += n * (n - 1)", "+ ans += n"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4702084679, "measured_runtime_v1": 0.3054097801, "runtime_lift": 1.5395985934, "key": ["s746150122", "s989284284"]} {"user_id": "u476068053", "problem_id": "p02555", "language": "python", "submission_id_v0": "s269976358", "submission_id_v1": "s000228897", "cpu_time_v0": 91, "cpu_time_v1": 66, "memory_v0": 64552, "memory_v1": 62952, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 27.47, "input": "def main():\n\n s = int(input())\n\n mod = 10**9 + 7\n\n\n\n dp = [0] * (s+1)\n\n dp[0] = 1\n\n for i in range(1, s+1):\n\n for j in range(0, (i-3)+1):\n\n dp[i] += dp[j]\n\n dp[i] %= mod\n\n print((dp[-1]))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "def main():\n\n s = int(input())\n\n mod = 10**9 + 7\n\n\n\n dp = [0] * (s+1)\n\n dp[0] = 1\n\n# for i in range(1, s+1):\n\n# for j in range(0, (i-3)+1):\n\n# dp[i] += dp[j]\n\n# dp[i] %= mod\n\n for i in range(1, s+1):\n\n if i < 3:\n\n dp[i] = 0\n\n else:\n\n dp[i] = dp[i-1] + dp[i-3]\n\n dp[i] %= mod\n\n\n\n print((dp[-1]))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "code_v0_loc": 15, "code_v1_loc": 22, "code_v0_num_chars": 277, "code_v1_num_chars": 434, "code_v0_no_empty_lines": "def main():\n s = int(input())\n mod = 10**9 + 7\n dp = [0] * (s + 1)\n dp[0] = 1\n for i in range(1, s + 1):\n for j in range(0, (i - 3) + 1):\n dp[i] += dp[j]\n dp[i] %= mod\n print((dp[-1]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n s = int(input())\n mod = 10**9 + 7\n dp = [0] * (s + 1)\n dp[0] = 1\n # for i in range(1, s+1):\n # for j in range(0, (i-3)+1):\n # dp[i] += dp[j]\n # dp[i] %= mod\n for i in range(1, s + 1):\n if i < 3:\n dp[i] = 0\n else:\n dp[i] = dp[i - 1] + dp[i - 3]\n dp[i] %= mod\n print((dp[-1]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 31.8181818182, "diff": ["+ # for i in range(1, s+1):", "+ # for j in range(0, (i-3)+1):", "+ # dp[i] += dp[j]", "+ # dp[i] %= mod", "- for j in range(0, (i - 3) + 1):", "- dp[i] += dp[j]", "+ if i < 3:", "+ dp[i] = 0", "+ else:", "+ dp[i] = dp[i - 1] + dp[i - 3]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.5094247258, "measured_runtime_v1": 0.2087815866, "runtime_lift": 2.4399887649, "key": ["s269976358", "s000228897"]} {"user_id": "u077291787", "problem_id": "p03164", "language": "python", "submission_id_v0": "s644346369", "submission_id_v1": "s649660252", "cpu_time_v0": 472, "cpu_time_v1": 351, "memory_v0": 93244, "memory_v1": 70732, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.64, "input": "# temp\n\nn,w = list(map(int,input().split()))\n\nwv = [tuple(map(int,input().split())) for i in range(n)]\n\n\n\ndp = [0] + [float(\"inf\")]*(10**5)\n\nfor i in range(n):\n\n for j in range(10**5,wv[i][1]-1,-1):\n\n dp[j] = min(dp[j],dp[j-wv[i][1]]+wv[i][0])\n\n\n\nres = 0\n\nfor v,e in enumerate(dp):\n\n if e <= w:\n\n res = v\n\nprint(res)", "target": "# dpE - Knapsack 2\n\nimport sys\n\ninput = sys.stdin.readline\n\n\n\ndef main():\n\n n, W = tuple(map(int, input().rstrip().split()))\n\n A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))\n\n _, v = list(zip(*A))\n\n lim = sum(v)\n\n dp = [0] + [float(\"inf\")] * lim\n\n for i in range(n):\n\n for j in range(lim, A[i][1] - 1, -1):\n\n dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])\n\n ans = max(v for v, w in enumerate(dp) if w <= W)\n\n print(ans)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()", "code_v0_loc": 14, "code_v1_loc": 19, "code_v0_num_chars": 330, "code_v1_num_chars": 522, "code_v0_no_empty_lines": "# temp\nn, w = list(map(int, input().split()))\nwv = [tuple(map(int, input().split())) for i in range(n)]\ndp = [0] + [float(\"inf\")] * (10**5)\nfor i in range(n):\n for j in range(10**5, wv[i][1] - 1, -1):\n dp[j] = min(dp[j], dp[j - wv[i][1]] + wv[i][0])\nres = 0\nfor v, e in enumerate(dp):\n if e <= w:\n res = v\nprint(res)\n", "code_v1_no_empty_lines": "# dpE - Knapsack 2\nimport sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n n, W = tuple(map(int, input().rstrip().split()))\n A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))\n _, v = list(zip(*A))\n lim = sum(v)\n dp = [0] + [float(\"inf\")] * lim\n for i in range(n):\n for j in range(lim, A[i][1] - 1, -1):\n dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])\n ans = max(v for v, w in enumerate(dp) if w <= W)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 26.3157894737, "diff": ["-# temp", "-n, w = list(map(int, input().split()))", "-wv = [tuple(map(int, input().split())) for i in range(n)]", "-dp = [0] + [float(\"inf\")] * (10**5)", "-for i in range(n):", "- for j in range(10**5, wv[i][1] - 1, -1):", "- dp[j] = min(dp[j], dp[j - wv[i][1]] + wv[i][0])", "-res = 0", "-for v, e in enumerate(dp):", "- if e <= w:", "- res = v", "-print(res)", "+# dpE - Knapsack 2", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "+def main():", "+ n, W = tuple(map(int, input().rstrip().split()))", "+ A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))", "+ _, v = list(zip(*A))", "+ lim = sum(v)", "+ dp = [0] + [float(\"inf\")] * lim", "+ for i in range(n):", "+ for j in range(lim, A[i][1] - 1, -1):", "+ dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])", "+ ans = max(v for v, w in enumerate(dp) if w <= W)", "+ print(ans)", "+", "+", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 1.6859776349, "measured_runtime_v1": 0.2345220137, "runtime_lift": 7.1889952184, "key": ["s644346369", "s649660252"]} {"user_id": "u254871849", "problem_id": "p03086", "language": "python", "submission_id_v0": "s827296868", "submission_id_v1": "s358574733", "cpu_time_v0": 604, "cpu_time_v1": 18, "memory_v0": 102680, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 97.02, "input": "# 2019-11-12 22:21:08(JST)\n\nimport sys\n\n# import collections\n\n# import math\n\n# from string import ascii_lowercase, ascii_uppercase, digits\n\n# from bisect import bisect_left as bi_l, bisect_right as bi_r\n\nimport itertools\n\n# from functools import reduce\n\n# import operator as op\n\n# from scipy.misc import comb # float\n\n# import numpy as np \n\n\n\ndef main():\n\n s = sys.stdin.readline().rstrip()\n\n \n\n all_words = []\n\n for i in range(1, len(s) + 1):\n\n for letters in itertools.product('ATCG', repeat=i):\n\n word = ''.join(letters)\n\n all_words.append(word)\n\n \n\n for i in range(len(all_words)-1, 0-1, -1):\n\n if all_words[i] in s:\n\n print((len(all_words[i])))\n\n sys.exit()\n\n print((0))\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "# 2019-11-12 22:21:08(JST)\n\nimport sys\n\n# import collections\n\n# import math\n\n# from string import ascii_lowercase, ascii_uppercase, digits\n\n# from bisect import bisect_left as bi_l, bisect_right as bi_r\n\n# import itertools\n\n# from functools import reduce\n\n# import operator as op\n\n# from scipy.misc import comb # float\n\n# import numpy as np \n\n\n\ndef main():\n\n s = sys.stdin.readline().rstrip()\n\n \n\n permitted = 'ACGT'\n\n continuous_count = []\n\n count = 0\n\n\n\n for i in range(len(s)):\n\n char = s[i]\n\n if char in permitted:\n\n count += 1\n\n else:\n\n continuous_count.append(count)\n\n count = 0\n\n if i == len(s) - 1:\n\n continuous_count.append(count)\n\n \n\n if not continuous_count:\n\n print((len(s)))\n\n else:\n\n print((max(continuous_count)))\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "code_v0_loc": 32, "code_v1_loc": 38, "code_v0_num_chars": 799, "code_v1_num_chars": 884, "code_v0_no_empty_lines": "# 2019-11-12 22:21:08(JST)\nimport sys\n\n# import collections\n# import math\n# from string import ascii_lowercase, ascii_uppercase, digits\n# from bisect import bisect_left as bi_l, bisect_right as bi_r\nimport itertools\n\n# from functools import reduce\n# import operator as op\n# from scipy.misc import comb # float\n# import numpy as np\ndef main():\n s = sys.stdin.readline().rstrip()\n all_words = []\n for i in range(1, len(s) + 1):\n for letters in itertools.product(\"ATCG\", repeat=i):\n word = \"\".join(letters)\n all_words.append(word)\n for i in range(len(all_words) - 1, 0 - 1, -1):\n if all_words[i] in s:\n print((len(all_words[i])))\n sys.exit()\n print((0))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "# 2019-11-12 22:21:08(JST)\nimport sys\n\n# import collections\n# import math\n# from string import ascii_lowercase, ascii_uppercase, digits\n# from bisect import bisect_left as bi_l, bisect_right as bi_r\n# import itertools\n# from functools import reduce\n# import operator as op\n# from scipy.misc import comb # float\n# import numpy as np\ndef main():\n s = sys.stdin.readline().rstrip()\n permitted = \"ACGT\"\n continuous_count = []\n count = 0\n for i in range(len(s)):\n char = s[i]\n if char in permitted:\n count += 1\n else:\n continuous_count.append(count)\n count = 0\n if i == len(s) - 1:\n continuous_count.append(count)\n if not continuous_count:\n print((len(s)))\n else:\n print((max(continuous_count)))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 15.7894736842, "diff": ["-import itertools", "-", "+# import itertools", "- all_words = []", "- for i in range(1, len(s) + 1):", "- for letters in itertools.product(\"ATCG\", repeat=i):", "- word = \"\".join(letters)", "- all_words.append(word)", "- for i in range(len(all_words) - 1, 0 - 1, -1):", "- if all_words[i] in s:", "- print((len(all_words[i])))", "- sys.exit()", "- print((0))", "+ permitted = \"ACGT\"", "+ continuous_count = []", "+ count = 0", "+ for i in range(len(s)):", "+ char = s[i]", "+ if char in permitted:", "+ count += 1", "+ else:", "+ continuous_count.append(count)", "+ count = 0", "+ if i == len(s) - 1:", "+ continuous_count.append(count)", "+ if not continuous_count:", "+ print((len(s)))", "+ else:", "+ print((max(continuous_count)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4624249086, "measured_runtime_v1": 0.2736470122, "runtime_lift": 1.6898591541, "key": ["s827296868", "s358574733"]} {"user_id": "u150984829", "problem_id": "p02386", "language": "python", "submission_id_v0": "s352388599", "submission_id_v1": "s199670495", "cpu_time_v0": 40, "cpu_time_v1": 30, "memory_v0": 5616, "memory_v1": 5616, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.0, "input": "n=int(input())\n\na=[list(map(int,input().split()))for _ in range(n)]\n\ndef f():\n\n for i in range(n-1):\n\n d=a[i][:];d[3],d[4]=d[4],d[3]\n\n for j in range(i+1,n):\n\n e=a[j][:];e[3],e[4]=e[4],e[3]\n\n for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):\n\n f=[d[k]for k in p]\n\n if f[0]==e[0]and f[5]==e[5]:\n\n f=f[1:5]*2\n\n for k in range(4):\n\n if f[k:k+4]==e[1:5]:return'No'\n\n return'Yes'\n\nprint((f()))\n", "target": "n=int(input())\n\na=[[int(s)for s in input().split()]for _ in range(n)]\n\ndef f():\n\n for i in range(n-1):\n\n d=a[i][:];d[3],d[4]=d[4],d[3]\n\n for j in range(i+1,n):\n\n e=a[j][:];e[3],e[4]=e[4],e[3]\n\n for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):\n\n f=[d[k]for k in p]\n\n if f[0]==e[0]and f[5]==e[5]:\n\n f=f[1:5]*2\n\n for k in range(4):\n\n if f[k:k+4]==e[1:5]:return'No'\n\n return'Yes'\n\nprint((f()))\n", "code_v0_loc": 15, "code_v1_loc": 15, "code_v0_num_chars": 457, "code_v1_num_chars": 459, "code_v0_no_empty_lines": "n = int(input())\na = [list(map(int, input().split())) for _ in range(n)]\n\n\ndef f():\n for i in range(n - 1):\n d = a[i][:]\n d[3], d[4] = d[4], d[3]\n for j in range(i + 1, n):\n e = a[j][:]\n e[3], e[4] = e[4], e[3]\n for p in (\n [0, 1, 2, 3, 4, 5],\n [1, 5, 2, 0, 4, 3],\n [2, 1, 5, 3, 0, 4],\n [3, 0, 2, 5, 4, 1],\n [4, 1, 0, 3, 5, 2],\n [5, 1, 4, 3, 2, 0],\n ):\n f = [d[k] for k in p]\n if f[0] == e[0] and f[5] == e[5]:\n f = f[1:5] * 2\n for k in range(4):\n if f[k : k + 4] == e[1:5]:\n return \"No\"\n return \"Yes\"\n\n\nprint((f()))\n", "code_v1_no_empty_lines": "n = int(input())\na = [[int(s) for s in input().split()] for _ in range(n)]\n\n\ndef f():\n for i in range(n - 1):\n d = a[i][:]\n d[3], d[4] = d[4], d[3]\n for j in range(i + 1, n):\n e = a[j][:]\n e[3], e[4] = e[4], e[3]\n for p in (\n [0, 1, 2, 3, 4, 5],\n [1, 5, 2, 0, 4, 3],\n [2, 1, 5, 3, 0, 4],\n [3, 0, 2, 5, 4, 1],\n [4, 1, 0, 3, 5, 2],\n [5, 1, 4, 3, 2, 0],\n ):\n f = [d[k] for k in p]\n if f[0] == e[0] and f[5] == e[5]:\n f = f[1:5] * 2\n for k in range(4):\n if f[k : k + 4] == e[1:5]:\n return \"No\"\n return \"Yes\"\n\n\nprint((f()))\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["-a = [list(map(int, input().split())) for _ in range(n)]", "+a = [[int(s) for s in input().split()] for _ in range(n)]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2724710764, "measured_runtime_v1": 0.2146971788, "runtime_lift": 1.2690948152, "key": ["s352388599", "s199670495"]} {"user_id": "u153665391", "problem_id": "p02268", "language": "python", "submission_id_v0": "s156684058", "submission_id_v1": "s820654012", "cpu_time_v0": 520, "cpu_time_v1": 390, "memory_v0": 16712, "memory_v1": 16712, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 25.0, "input": "N = int(input())\n\nS = list(map(int, input().split()))\n\nQ = int(input())\n\nT = list(map(int, input().split()))\n\n\n\ndef binary_search(target_num, head, tail):\n\n idx = int((head+tail)/2)\n\n if target_num == S[idx]:\n\n return True\n\n elif target_num < S[idx]:\n\n if head == idx:\n\n return False\n\n return binary_search(target_num, head, idx-1)\n\n else:\n\n if tail == idx:\n\n return False\n\n return binary_search(target_num, idx+1, tail)\n\n\n\n\n\nmatch_count = 0\n\nfor target_num in T:\n\n if binary_search(target_num, 0, len(S)-1):\n\n match_count += 1\n\n\n\nprint((str(match_count)))\n", "target": "N = int(input())\n\nS = list(map(int, input().split()))\n\nQ = int(input())\n\nT = list(map(int, input().split()))\n\n\n\ndef binary_search(target_num, head, tail):\n\n while head <= tail:\n\n idx = int((head+tail)/2)\n\n if target_num == S[idx]:\n\n return True\n\n elif target_num < S[idx]:\n\n tail = idx - 1\n\n else:\n\n head = idx + 1\n\n return False\n\n\n\n\n\nmatch_count = 0\n\nfor target_num in T:\n\n if binary_search(target_num, 0, len(S)-1):\n\n match_count += 1\n\n\n\nprint((str(match_count)))\n", "code_v0_loc": 25, "code_v1_loc": 23, "code_v0_num_chars": 634, "code_v1_num_chars": 541, "code_v0_no_empty_lines": "N = int(input())\nS = list(map(int, input().split()))\nQ = int(input())\nT = list(map(int, input().split()))\n\n\ndef binary_search(target_num, head, tail):\n idx = int((head + tail) / 2)\n if target_num == S[idx]:\n return True\n elif target_num < S[idx]:\n if head == idx:\n return False\n return binary_search(target_num, head, idx - 1)\n else:\n if tail == idx:\n return False\n return binary_search(target_num, idx + 1, tail)\n\n\nmatch_count = 0\nfor target_num in T:\n if binary_search(target_num, 0, len(S) - 1):\n match_count += 1\nprint((str(match_count)))\n", "code_v1_no_empty_lines": "N = int(input())\nS = list(map(int, input().split()))\nQ = int(input())\nT = list(map(int, input().split()))\n\n\ndef binary_search(target_num, head, tail):\n while head <= tail:\n idx = int((head + tail) / 2)\n if target_num == S[idx]:\n return True\n elif target_num < S[idx]:\n tail = idx - 1\n else:\n head = idx + 1\n return False\n\n\nmatch_count = 0\nfor target_num in T:\n if binary_search(target_num, 0, len(S) - 1):\n match_count += 1\nprint((str(match_count)))\n", "code_same": false, "relative_loc_diff_percent": 8.0, "diff": ["- idx = int((head + tail) / 2)", "- if target_num == S[idx]:", "- return True", "- elif target_num < S[idx]:", "- if head == idx:", "- return False", "- return binary_search(target_num, head, idx - 1)", "- else:", "- if tail == idx:", "- return False", "- return binary_search(target_num, idx + 1, tail)", "+ while head <= tail:", "+ idx = int((head + tail) / 2)", "+ if target_num == S[idx]:", "+ return True", "+ elif target_num < S[idx]:", "+ tail = idx - 1", "+ else:", "+ head = idx + 1", "+ return False"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3635195796, "measured_runtime_v1": 0.2206529045, "runtime_lift": 1.6474724429, "key": ["s156684058", "s820654012"]} {"user_id": "u887207211", "problem_id": "p03086", "language": "python", "submission_id_v0": "s916999030", "submission_id_v1": "s575230730", "cpu_time_v0": 19, "cpu_time_v1": 17, "memory_v0": 3188, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 10.53, "input": "import re\n\nptn = re.compile(r\"(A|C|G|T)*\")\n\n\n\nS = input()\n\n\n\nans = 0\n\nfor i in range(len(S)):\n\n for j in range(len(S)):\n\n x = ptn.match(S[i:i+j+1]).group(0)\n\n if(x):\n\n ans = max(ans, len(x))\n\nprint(ans)", "target": "import sys\n\n\n\nstdin = sys.stdin\n\n\n\nns = lambda : stdin.readline().rstrip()\n\nni = lambda : int(ns())\n\nna = lambda : list(map(int, stdin.readline().split()))\n\nsys.setrecursionlimit(10 ** 7)\n\n\n\ndef check(In):\n\n return In != \"A\" and In != \"C\" and In != \"G\" and In != \"T\"\n\n\n\ndef main():\n\n s = ns()\n\n\n\n count = 0\n\n ans = 0\n\n for i in range(len(s)):\n\n if check(s[i]):\n\n count = 0\n\n else:\n\n count += 1\n\n ans = max(ans, count)\n\n print(ans)\n\n\n\nif __name__ == '__main__':\n\n main()", "code_v0_loc": 12, "code_v1_loc": 27, "code_v0_num_chars": 214, "code_v1_num_chars": 537, "code_v0_no_empty_lines": "import re\n\nptn = re.compile(r\"(A|C|G|T)*\")\nS = input()\nans = 0\nfor i in range(len(S)):\n for j in range(len(S)):\n x = ptn.match(S[i : i + j + 1]).group(0)\n if x:\n ans = max(ans, len(x))\nprint(ans)\n", "code_v1_no_empty_lines": "import sys\n\nstdin = sys.stdin\nns = lambda: stdin.readline().rstrip()\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nsys.setrecursionlimit(10**7)\n\n\ndef check(In):\n return In != \"A\" and In != \"C\" and In != \"G\" and In != \"T\"\n\n\ndef main():\n s = ns()\n count = 0\n ans = 0\n for i in range(len(s)):\n if check(s[i]):\n count = 0\n else:\n count += 1\n ans = max(ans, count)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 55.5555555556, "diff": ["-import re", "+import sys", "-ptn = re.compile(r\"(A|C|G|T)*\")", "-S = input()", "-ans = 0", "-for i in range(len(S)):", "- for j in range(len(S)):", "- x = ptn.match(S[i : i + j + 1]).group(0)", "- if x:", "- ans = max(ans, len(x))", "-print(ans)", "+stdin = sys.stdin", "+ns = lambda: stdin.readline().rstrip()", "+ni = lambda: int(ns())", "+na = lambda: list(map(int, stdin.readline().split()))", "+sys.setrecursionlimit(10**7)", "+", "+", "+def check(In):", "+ return In != \"A\" and In != \"C\" and In != \"G\" and In != \"T\"", "+", "+", "+def main():", "+ s = ns()", "+ count = 0", "+ ans = 0", "+ for i in range(len(s)):", "+ if check(s[i]):", "+ count = 0", "+ else:", "+ count += 1", "+ ans = max(ans, count)", "+ print(ans)", "+", "+", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3654596429, "measured_runtime_v1": 0.2052364919, "runtime_lift": 1.7806757436, "key": ["s916999030", "s575230730"]} {"user_id": "u489959379", "problem_id": "p03371", "language": "python", "submission_id_v0": "s775348159", "submission_id_v1": "s575049266", "cpu_time_v0": 62, "cpu_time_v1": 17, "memory_v0": 3316, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 72.58, "input": "a, b, c, x, y = list(map(int, input().split()))\n\nab = c * 2\n\n\n\nres = float(\"inf\")\n\nif a + b <= ab:\n\n res = x * a + y * b\n\nelse:\n\n if x == y:\n\n res = x * ab\n\n elif x > y:\n\n for i in range(y, x + 1):\n\n cost = i * ab + (x - i) * a\n\n res = min(res, cost)\n\n else:\n\n for i in range(x, y + 1):\n\n cost = i * ab + (y - i) * b\n\n res = min(res, cost)\n\nprint(res)\n", "target": "import sys\n\n\n\nsys.setrecursionlimit(10 ** 7)\n\ninput = sys.stdin.readline\n\nf_inf = float('inf')\n\nmod = 10 ** 9 + 7\n\n\n\n\n\ndef resolve():\n\n a, b, c, x, y = list(map(int, input().split()))\n\n c *= 2\n\n if a + b > c:\n\n cost1 = max(x, y) * c\n\n cost2 = min(x, y) * c\n\n plus = ((y - x) * b) if x < y else (x - y) * a\n\n res = min(cost1, cost2 + plus)\n\n else:\n\n res = x * a + y * b\n\n print(res)\n\n\n\nif __name__ == '__main__':\n\n resolve()\n", "code_v0_loc": 18, "code_v1_loc": 22, "code_v0_num_chars": 423, "code_v1_num_chars": 471, "code_v0_no_empty_lines": "a, b, c, x, y = list(map(int, input().split()))\nab = c * 2\nres = float(\"inf\")\nif a + b <= ab:\n res = x * a + y * b\nelse:\n if x == y:\n res = x * ab\n elif x > y:\n for i in range(y, x + 1):\n cost = i * ab + (x - i) * a\n res = min(res, cost)\n else:\n for i in range(x, y + 1):\n cost = i * ab + (y - i) * b\n res = min(res, cost)\nprint(res)\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\nf_inf = float(\"inf\")\nmod = 10**9 + 7\n\n\ndef resolve():\n a, b, c, x, y = list(map(int, input().split()))\n c *= 2\n if a + b > c:\n cost1 = max(x, y) * c\n cost2 = min(x, y) * c\n plus = ((y - x) * b) if x < y else (x - y) * a\n res = min(cost1, cost2 + plus)\n else:\n res = x * a + y * b\n print(res)\n\n\nif __name__ == \"__main__\":\n resolve()\n", "code_same": false, "relative_loc_diff_percent": 18.1818181818, "diff": ["-a, b, c, x, y = list(map(int, input().split()))", "-ab = c * 2", "-res = float(\"inf\")", "-if a + b <= ab:", "- res = x * a + y * b", "-else:", "- if x == y:", "- res = x * ab", "- elif x > y:", "- for i in range(y, x + 1):", "- cost = i * ab + (x - i) * a", "- res = min(res, cost)", "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+input = sys.stdin.readline", "+f_inf = float(\"inf\")", "+mod = 10**9 + 7", "+", "+", "+def resolve():", "+ a, b, c, x, y = list(map(int, input().split()))", "+ c *= 2", "+ if a + b > c:", "+ cost1 = max(x, y) * c", "+ cost2 = min(x, y) * c", "+ plus = ((y - x) * b) if x < y else (x - y) * a", "+ res = min(cost1, cost2 + plus)", "- for i in range(x, y + 1):", "- cost = i * ab + (y - i) * b", "- res = min(res, cost)", "-print(res)", "+ res = x * a + y * b", "+ print(res)", "+", "+", "+if __name__ == \"__main__\":", "+ resolve()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3014842281, "measured_runtime_v1": 0.1645996099, "runtime_lift": 1.8316217662, "key": ["s775348159", "s575049266"]} {"user_id": "u291766461", "problem_id": "p03074", "language": "python", "submission_id_v0": "s221518045", "submission_id_v1": "s305948108", "cpu_time_v0": 149, "cpu_time_v1": 123, "memory_v0": 4212, "memory_v1": 7884, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 17.45, "input": "N, K = list(map(int, input().split()))\n\nS = input()\n\nnums = []\n\nnow = 1\n\ncnt = 0\n\nfor i in range(N):\n\n if S[i] == str(now):\n\n cnt += 1\n\n else:\n\n nums.append(cnt)\n\n now = 1 - now\n\n cnt = 1\n\nif cnt != 0:\n\n nums.append(cnt)\n\nif len(nums) % 2 == 0:\n\n nums.append(0)\n\n\n\nadd = 2 * K + 1\n\nans = 0\n\nleft = 0\n\nright = 0\n\ntmp = 0\n\nfor i in range(0, len(nums), 2):\n\n\n\n next_left = i\n\n next_right = min(i + add, len(nums))\n\n\n\n while next_left > left:\n\n tmp -= nums[left]\n\n left += 1\n\n\n\n while next_right > right:\n\n tmp += nums[right]\n\n right += 1\n\n\n\n ans = max(ans, tmp)\n\nprint(ans)", "target": "N, K = list(map(int, input().split()))\n\nS = input()\n\nnums = []\n\nnow = 1\n\ncnt = 0\n\nfor i in range(N):\n\n if S[i] == str(now):\n\n cnt += 1\n\n else:\n\n nums.append(cnt)\n\n now = 1 - now\n\n cnt = 1\n\nif cnt != 0:\n\n nums.append(cnt)\n\nif len(nums) % 2 == 0:\n\n nums.append(0)\n\n\n\ncsum = [0] * (len(nums) + 1)\n\nfor i in range(len(nums)):\n\n csum[i + 1] = csum[i] + nums[i]\n\n\n\nadd = 2 * K + 1\n\nans = 0\n\ntmp = 0\n\nfor i in range(0, len(nums), 2):\n\n left = i\n\n right = min(i + add, len(nums))\n\n tmp = csum[right] - csum[left]\n\n ans = max(ans, tmp)\n\nprint(ans)", "code_v0_loc": 37, "code_v1_loc": 30, "code_v0_num_chars": 647, "code_v1_num_chars": 587, "code_v0_no_empty_lines": "N, K = list(map(int, input().split()))\nS = input()\nnums = []\nnow = 1\ncnt = 0\nfor i in range(N):\n if S[i] == str(now):\n cnt += 1\n else:\n nums.append(cnt)\n now = 1 - now\n cnt = 1\nif cnt != 0:\n nums.append(cnt)\nif len(nums) % 2 == 0:\n nums.append(0)\nadd = 2 * K + 1\nans = 0\nleft = 0\nright = 0\ntmp = 0\nfor i in range(0, len(nums), 2):\n next_left = i\n next_right = min(i + add, len(nums))\n while next_left > left:\n tmp -= nums[left]\n left += 1\n while next_right > right:\n tmp += nums[right]\n right += 1\n ans = max(ans, tmp)\nprint(ans)\n", "code_v1_no_empty_lines": "N, K = list(map(int, input().split()))\nS = input()\nnums = []\nnow = 1\ncnt = 0\nfor i in range(N):\n if S[i] == str(now):\n cnt += 1\n else:\n nums.append(cnt)\n now = 1 - now\n cnt = 1\nif cnt != 0:\n nums.append(cnt)\nif len(nums) % 2 == 0:\n nums.append(0)\ncsum = [0] * (len(nums) + 1)\nfor i in range(len(nums)):\n csum[i + 1] = csum[i] + nums[i]\nadd = 2 * K + 1\nans = 0\ntmp = 0\nfor i in range(0, len(nums), 2):\n left = i\n right = min(i + add, len(nums))\n tmp = csum[right] - csum[left]\n ans = max(ans, tmp)\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 18.9189189189, "diff": ["+csum = [0] * (len(nums) + 1)", "+for i in range(len(nums)):", "+ csum[i + 1] = csum[i] + nums[i]", "-left = 0", "-right = 0", "- next_left = i", "- next_right = min(i + add, len(nums))", "- while next_left > left:", "- tmp -= nums[left]", "- left += 1", "- while next_right > right:", "- tmp += nums[right]", "- right += 1", "+ left = i", "+ right = min(i + add, len(nums))", "+ tmp = csum[right] - csum[left]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2166490428, "measured_runtime_v1": 0.0894378448, "runtime_lift": 2.422341945, "key": ["s221518045", "s305948108"]} {"user_id": "u670180528", "problem_id": "p03253", "language": "python", "submission_id_v0": "s289323588", "submission_id_v1": "s397757622", "cpu_time_v0": 97, "cpu_time_v1": 24, "memory_v0": 11252, "memory_v1": 3564, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 75.26, "input": "from collections import Counter\n\ndef factorization(n) -> list:\n\n\tif n==1:\n\n\t\treturn [1]\n\n\tret = []\n\n\ti = 2\n\n\twhile i*i<=n:\n\n\t\twhile n%i==0:\n\n\t\t\tn //= i\n\n\t\t\tret.append(i)\n\n\t\ti += 1\n\n\tif n!=1:\n\n\t\tret.append(n)\n\n\treturn ret\n\n\n\nn,m = list(map(int,input().split()))\n\nmod = 10**9+7\n\nif m==1:\n\n\tprint((1));exit()\n\n\n\nfactors = Counter(factorization(m))\n\nmx = n+max(factors.values())\n\n\n\nfac = [1]*(mx+1)\n\ninv = [1]*(mx+1)\n\nfor i in range(1,mx+1):\n\n\tfac[i] = fac[i-1] * i % mod\n\ninv[-1] = pow(fac[-1], mod - 2, mod)\n\nfor i in range(mx-1, -1, -1):\n\n\tinv[i] = inv[i+1] * (i+1) % mod\n\ndef cmb(n,r):\n\n\tassert n >= r >= 0\n\n\treturn fac[n] * inv[n-r] * inv[r] % mod\n\n\t\n\nans=1\n\nfor v in list(factors.values()):\n\n\tans*=cmb(n+v-1,v)\n\n\tans%=mod\n\n\n\nprint(ans)", "target": "from collections import Counter\n\ndef factorization(n) -> list:\n\n\tif n==1:return [1]\n\n\tret = []\n\n\ti = 2\n\n\twhile i*i<=n:\n\n\t\twhile n%i==0:\n\n\t\t\tn //= i\n\n\t\t\tret.append(i)\n\n\t\ti += 1\n\n\tif n!=1:ret.append(n)\n\n\treturn ret\n\n\t\n\nfrom operator import mul\n\nfrom functools import reduce\n\ndef cmb(n,r):\n\n\tif n < r:return 0\n\n\tr = min(n-r,r)\n\n\tif r==0:return 1\n\n\tu = reduce(mul, list(range(n, n-r, -1)))\n\n\td = reduce(mul, list(range(1,r+1)))\n\n\treturn u//d\n\n\n\ndef main():\n\n\tn,m = list(map(int,input().split()))\n\n\tmod = 10**9+7\n\n\tif m==1:\n\n\t\tprint((1))\n\n\t\texit()\n\n\tans=1\n\n\tfor v in list(Counter(factorization(m)).values()):\n\n\t\tans*=cmb(n+v-1,v)\n\n\t\tans%=mod\n\n\tprint(ans)\n\n\t\n\nif __name__==\"__main__\":main()", "code_v0_loc": 40, "code_v1_loc": 36, "code_v0_num_chars": 723, "code_v1_num_chars": 658, "code_v0_no_empty_lines": "from collections import Counter\n\n\ndef factorization(n) -> list:\n if n == 1:\n return [1]\n ret = []\n i = 2\n while i * i <= n:\n while n % i == 0:\n n //= i\n ret.append(i)\n i += 1\n if n != 1:\n ret.append(n)\n return ret\n\n\nn, m = list(map(int, input().split()))\nmod = 10**9 + 7\nif m == 1:\n print((1))\n exit()\nfactors = Counter(factorization(m))\nmx = n + max(factors.values())\nfac = [1] * (mx + 1)\ninv = [1] * (mx + 1)\nfor i in range(1, mx + 1):\n fac[i] = fac[i - 1] * i % mod\ninv[-1] = pow(fac[-1], mod - 2, mod)\nfor i in range(mx - 1, -1, -1):\n inv[i] = inv[i + 1] * (i + 1) % mod\n\n\ndef cmb(n, r):\n assert n >= r >= 0\n return fac[n] * inv[n - r] * inv[r] % mod\n\n\nans = 1\nfor v in list(factors.values()):\n ans *= cmb(n + v - 1, v)\n ans %= mod\nprint(ans)\n", "code_v1_no_empty_lines": "from collections import Counter\n\n\ndef factorization(n) -> list:\n if n == 1:\n return [1]\n ret = []\n i = 2\n while i * i <= n:\n while n % i == 0:\n n //= i\n ret.append(i)\n i += 1\n if n != 1:\n ret.append(n)\n return ret\n\n\nfrom operator import mul\nfrom functools import reduce\n\n\ndef cmb(n, r):\n if n < r:\n return 0\n r = min(n - r, r)\n if r == 0:\n return 1\n u = reduce(mul, list(range(n, n - r, -1)))\n d = reduce(mul, list(range(1, r + 1)))\n return u // d\n\n\ndef main():\n n, m = list(map(int, input().split()))\n mod = 10**9 + 7\n if m == 1:\n print((1))\n exit()\n ans = 1\n for v in list(Counter(factorization(m)).values()):\n ans *= cmb(n + v - 1, v)\n ans %= mod\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 10.0, "diff": ["-n, m = list(map(int, input().split()))", "-mod = 10**9 + 7", "-if m == 1:", "- print((1))", "- exit()", "-factors = Counter(factorization(m))", "-mx = n + max(factors.values())", "-fac = [1] * (mx + 1)", "-inv = [1] * (mx + 1)", "-for i in range(1, mx + 1):", "- fac[i] = fac[i - 1] * i % mod", "-inv[-1] = pow(fac[-1], mod - 2, mod)", "-for i in range(mx - 1, -1, -1):", "- inv[i] = inv[i + 1] * (i + 1) % mod", "+from operator import mul", "+from functools import reduce", "- assert n >= r >= 0", "- return fac[n] * inv[n - r] * inv[r] % mod", "+ if n < r:", "+ return 0", "+ r = min(n - r, r)", "+ if r == 0:", "+ return 1", "+ u = reduce(mul, list(range(n, n - r, -1)))", "+ d = reduce(mul, list(range(1, r + 1)))", "+ return u // d", "-ans = 1", "-for v in list(factors.values()):", "- ans *= cmb(n + v - 1, v)", "- ans %= mod", "-print(ans)", "+def main():", "+ n, m = list(map(int, input().split()))", "+ mod = 10**9 + 7", "+ if m == 1:", "+ print((1))", "+ exit()", "+ ans = 1", "+ for v in list(Counter(factorization(m)).values()):", "+ ans *= cmb(n + v - 1, v)", "+ ans %= mod", "+ print(ans)", "+", "+", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4340592513, "measured_runtime_v1": 0.2881658652, "runtime_lift": 1.5062826786, "key": ["s289323588", "s397757622"]} {"user_id": "u738622346", "problem_id": "p03854", "language": "python", "submission_id_v0": "s146499990", "submission_id_v1": "s321967328", "cpu_time_v0": 123, "cpu_time_v1": 50, "memory_v0": 3316, "memory_v1": 3188, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 59.35, "input": "s = input()\n\nt = \"\"\n\nwhile len(t) < len(s):\n\n target_len = len(s) - len(t)\n\n\n\n if s[len(t)] == 'd':\n\n if target_len == 5:\n\n t += \"dream\"\n\n elif target_len == 7:\n\n t += \"dreamer\"\n\n elif target_len > 7:\n\n if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != \"era\":\n\n t += \"dreamer\"\n\n else:\n\n t += \"dream\"\n\n else:\n\n break\n\n else:\n\n if target_len == 5:\n\n t += \"erase\"\n\n elif target_len == 6:\n\n t += \"eraser\"\n\n elif target_len > 6:\n\n if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != \"era\":\n\n t += \"eraser\"\n\n else:\n\n t += \"erase\"\n\n else:\n\n break\n\n\n\n if s[0:len(t)] != t:\n\n break\n\n\n\nprint((\"YES\" if s == t else \"NO\"))\n", "target": "s = input()\n\ndiv = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]\n\nrev = []\n\nt = \"\"\n\ns_rev = s[::-1]\n\nfor d in div:\n\n rev.append(d[::-1])\n\n\n\nresult = True\n\ni = 0\n\nwhile i < len(s):\n\n can_divide = False\n\n for d in rev:\n\n if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:\n\n can_divide = True\n\n i += len(d)\n\n break\n\n if not can_divide:\n\n result = False\n\n break\n\n\n\nprint((\"YES\" if result else \"NO\"))\n", "code_v0_loc": 34, "code_v1_loc": 22, "code_v0_num_chars": 872, "code_v1_num_chars": 461, "code_v0_no_empty_lines": "s = input()\nt = \"\"\nwhile len(t) < len(s):\n target_len = len(s) - len(t)\n if s[len(t)] == \"d\":\n if target_len == 5:\n t += \"dream\"\n elif target_len == 7:\n t += \"dreamer\"\n elif target_len > 7:\n if s[len(t) + 5] != \"d\" and s[len(t) + 5 : len(t) + 7 + 1] != \"era\":\n t += \"dreamer\"\n else:\n t += \"dream\"\n else:\n break\n else:\n if target_len == 5:\n t += \"erase\"\n elif target_len == 6:\n t += \"eraser\"\n elif target_len > 6:\n if s[len(t) + 5] != \"d\" and s[len(t) + 5 : len(t) + 6 + 2] != \"era\":\n t += \"eraser\"\n else:\n t += \"erase\"\n else:\n break\n if s[0 : len(t)] != t:\n break\nprint((\"YES\" if s == t else \"NO\"))\n", "code_v1_no_empty_lines": "s = input()\ndiv = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]\nrev = []\nt = \"\"\ns_rev = s[::-1]\nfor d in div:\n rev.append(d[::-1])\nresult = True\ni = 0\nwhile i < len(s):\n can_divide = False\n for d in rev:\n if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d:\n can_divide = True\n i += len(d)\n break\n if not can_divide:\n result = False\n break\nprint((\"YES\" if result else \"NO\"))\n", "code_same": false, "relative_loc_diff_percent": 35.2941176471, "diff": ["+div = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "+rev = []", "-while len(t) < len(s):", "- target_len = len(s) - len(t)", "- if s[len(t)] == \"d\":", "- if target_len == 5:", "- t += \"dream\"", "- elif target_len == 7:", "- t += \"dreamer\"", "- elif target_len > 7:", "- if s[len(t) + 5] != \"d\" and s[len(t) + 5 : len(t) + 7 + 1] != \"era\":", "- t += \"dreamer\"", "- else:", "- t += \"dream\"", "- else:", "+s_rev = s[::-1]", "+for d in div:", "+ rev.append(d[::-1])", "+result = True", "+i = 0", "+while i < len(s):", "+ can_divide = False", "+ for d in rev:", "+ if len(s_rev) - i >= len(d) and s_rev[i : i + len(d)] == d:", "+ can_divide = True", "+ i += len(d)", "- else:", "- if target_len == 5:", "- t += \"erase\"", "- elif target_len == 6:", "- t += \"eraser\"", "- elif target_len > 6:", "- if s[len(t) + 5] != \"d\" and s[len(t) + 5 : len(t) + 6 + 2] != \"era\":", "- t += \"eraser\"", "- else:", "- t += \"erase\"", "- else:", "- break", "- if s[0 : len(t)] != t:", "+ if not can_divide:", "+ result = False", "-print((\"YES\" if s == t else \"NO\"))", "+print((\"YES\" if result else \"NO\"))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3984818382, "measured_runtime_v1": 0.3150180125, "runtime_lift": 1.2649493755, "key": ["s146499990", "s321967328"]} {"user_id": "u645250356", "problem_id": "p03559", "language": "python", "submission_id_v0": "s643210131", "submission_id_v1": "s973528764", "cpu_time_v0": 585, "cpu_time_v1": 431, "memory_v0": 124300, "memory_v1": 30272, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 26.32, "input": "from collections import Counter,defaultdict,deque\n\nfrom heapq import heappop,heappush,heapify\n\nimport sys,bisect,math,itertools,math,pprint\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\nINF = float('inf')\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\n\n\nn = inp()\n\nA = sorted(inpl())\n\nB = sorted(inpl())\n\nC = sorted(inpl())\n\ncnt = [0] * n\n\nres = 0\n\nfor i,b in enumerate(B):\n\n c = bisect.bisect_left(C,b+1)\n\n cnt[i] = n-c\n\n\n\nacc = [0]\n\nfor x in cnt:\n\n acc += [acc[-1] + x]\n\nsu = sum(cnt) \n\nfor i,a in enumerate(A):\n\n c = bisect.bisect_left(B,a+1)\n\n res += su - acc[c]\n\nprint(res)", "target": "from collections import Counter,defaultdict,deque\n\nfrom heapq import heappop,heappush,heapify\n\nimport sys,bisect,math,itertools,math,pprint\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\nINF = float('inf')\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\n\n\nn = inp()\n\na = inpl()\n\nb = inpl()\n\nc = inpl()\n\na.sort()\n\nb.sort()\n\nc.sort()\n\nlb = [0] * n\n\nres = 0\n\nfor i in range(n):\n\n tmp = bisect.bisect_right(b,a[i])\n\n if tmp == n: continue\n\n lb[tmp] += 1\n\nllb = list(itertools.accumulate(lb))\n\n# print(lb,llb)\n\nrr = [0] * n\n\nfor i in range(n):\n\n tmp = bisect.bisect_right(c,b[i])\n\n if tmp == n: continue\n\n rr[tmp] += llb[i]\n\nprint((sum(list(itertools.accumulate(rr)))))", "code_v0_loc": 27, "code_v1_loc": 30, "code_v0_num_chars": 662, "code_v1_num_chars": 747, "code_v0_no_empty_lines": "from collections import Counter, defaultdict, deque\nfrom heapq import heappop, heappush, heapify\nimport sys, bisect, math, itertools, math, pprint\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\nINF = float(\"inf\")\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\nn = inp()\nA = sorted(inpl())\nB = sorted(inpl())\nC = sorted(inpl())\ncnt = [0] * n\nres = 0\nfor i, b in enumerate(B):\n c = bisect.bisect_left(C, b + 1)\n cnt[i] = n - c\nacc = [0]\nfor x in cnt:\n acc += [acc[-1] + x]\nsu = sum(cnt)\nfor i, a in enumerate(A):\n c = bisect.bisect_left(B, a + 1)\n res += su - acc[c]\nprint(res)\n", "code_v1_no_empty_lines": "from collections import Counter, defaultdict, deque\nfrom heapq import heappop, heappush, heapify\nimport sys, bisect, math, itertools, math, pprint\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\nINF = float(\"inf\")\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\nn = inp()\na = inpl()\nb = inpl()\nc = inpl()\na.sort()\nb.sort()\nc.sort()\nlb = [0] * n\nres = 0\nfor i in range(n):\n tmp = bisect.bisect_right(b, a[i])\n if tmp == n:\n continue\n lb[tmp] += 1\nllb = list(itertools.accumulate(lb))\n# print(lb,llb)\nrr = [0] * n\nfor i in range(n):\n tmp = bisect.bisect_right(c, b[i])\n if tmp == n:\n continue\n rr[tmp] += llb[i]\nprint((sum(list(itertools.accumulate(rr)))))\n", "code_same": false, "relative_loc_diff_percent": 10.0, "diff": ["-A = sorted(inpl())", "-B = sorted(inpl())", "-C = sorted(inpl())", "-cnt = [0] * n", "+a = inpl()", "+b = inpl()", "+c = inpl()", "+a.sort()", "+b.sort()", "+c.sort()", "+lb = [0] * n", "-for i, b in enumerate(B):", "- c = bisect.bisect_left(C, b + 1)", "- cnt[i] = n - c", "-acc = [0]", "-for x in cnt:", "- acc += [acc[-1] + x]", "-su = sum(cnt)", "-for i, a in enumerate(A):", "- c = bisect.bisect_left(B, a + 1)", "- res += su - acc[c]", "-print(res)", "+for i in range(n):", "+ tmp = bisect.bisect_right(b, a[i])", "+ if tmp == n:", "+ continue", "+ lb[tmp] += 1", "+llb = list(itertools.accumulate(lb))", "+# print(lb,llb)", "+rr = [0] * n", "+for i in range(n):", "+ tmp = bisect.bisect_right(c, b[i])", "+ if tmp == n:", "+ continue", "+ rr[tmp] += llb[i]", "+print((sum(list(itertools.accumulate(rr)))))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2585086877, "measured_runtime_v1": 0.0062210422, "runtime_lift": 41.5539198783, "key": ["s643210131", "s973528764"]} {"user_id": "u968166680", "problem_id": "p02814", "language": "python", "submission_id_v0": "s703991862", "submission_id_v1": "s702868581", "cpu_time_v0": 61, "cpu_time_v1": 44, "memory_v0": 13352, "memory_v1": 14092, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 27.87, "input": "import sys\n\nfrom math import gcd\n\n\n\nread = sys.stdin.read\n\nreadline = sys.stdin.readline\n\nreadlines = sys.stdin.readlines\n\nsys.setrecursionlimit(10 ** 9)\n\nINF = 1 << 60\n\n\n\n\n\ndef lcm(x, y):\n\n return x * y // gcd(x, y)\n\n\n\n\n\ndef main():\n\n N, M = list(map(int, input().split()))\n\n A = list(set(map(int, input().split(\" \"))))\n\n A = [a // 2 for a in A]\n\n semi_lcm = 1\n\n for a in A:\n\n semi_lcm = lcm(semi_lcm, a)\n\n if semi_lcm > M:\n\n print((0))\n\n return\n\n\n\n for a in A:\n\n if semi_lcm // a % 2 == 0:\n\n print((0))\n\n return\n\n\n\n print(((M // semi_lcm + 1) // 2))\n\n return\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "import sys\n\n\n\nread = sys.stdin.read\n\nreadline = sys.stdin.readline\n\nreadlines = sys.stdin.readlines\n\nsys.setrecursionlimit(10 ** 9)\n\nINF = 1 << 60\n\n\n\n\n\ndef gcd(a, b):\n\n while b:\n\n a, b = b, a % b\n\n return a\n\n\n\n\n\ndef lcm(a, b):\n\n return a * b // gcd(a, b)\n\n\n\n\n\ndef main():\n\n N, M, *A = list(map(int, read().split()))\n\n A = list(set(A))\n\n B = A.copy()\n\n\n\n while not any(b % 2 for b in B):\n\n B = [b // 2 for b in B]\n\n\n\n if not all(b % 2 for b in B):\n\n print((0))\n\n return\n\n\n\n semi_lcm = 1\n\n for a in A:\n\n semi_lcm = lcm(semi_lcm, a // 2)\n\n\n\n print(((M // semi_lcm + 1) // 2))\n\n return\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 36, "code_v1_loc": 41, "code_v0_num_chars": 690, "code_v1_num_chars": 687, "code_v0_no_empty_lines": "import sys\nfrom math import gcd\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10**9)\nINF = 1 << 60\n\n\ndef lcm(x, y):\n return x * y // gcd(x, y)\n\n\ndef main():\n N, M = list(map(int, input().split()))\n A = list(set(map(int, input().split(\" \"))))\n A = [a // 2 for a in A]\n semi_lcm = 1\n for a in A:\n semi_lcm = lcm(semi_lcm, a)\n if semi_lcm > M:\n print((0))\n return\n for a in A:\n if semi_lcm // a % 2 == 0:\n print((0))\n return\n print(((M // semi_lcm + 1) // 2))\n return\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10**9)\nINF = 1 << 60\n\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\n\ndef main():\n N, M, *A = list(map(int, read().split()))\n A = list(set(A))\n B = A.copy()\n while not any(b % 2 for b in B):\n B = [b // 2 for b in B]\n if not all(b % 2 for b in B):\n print((0))\n return\n semi_lcm = 1\n for a in A:\n semi_lcm = lcm(semi_lcm, a // 2)\n print(((M // semi_lcm + 1) // 2))\n return\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 12.1951219512, "diff": ["-from math import gcd", "-def lcm(x, y):", "- return x * y // gcd(x, y)", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a", "+", "+", "+def lcm(a, b):", "+ return a * b // gcd(a, b)", "- N, M = list(map(int, input().split()))", "- A = list(set(map(int, input().split(\" \"))))", "- A = [a // 2 for a in A]", "+ N, M, *A = list(map(int, read().split()))", "+ A = list(set(A))", "+ B = A.copy()", "+ while not any(b % 2 for b in B):", "+ B = [b // 2 for b in B]", "+ if not all(b % 2 for b in B):", "+ print((0))", "+ return", "- semi_lcm = lcm(semi_lcm, a)", "- if semi_lcm > M:", "- print((0))", "- return", "- for a in A:", "- if semi_lcm // a % 2 == 0:", "- print((0))", "- return", "+ semi_lcm = lcm(semi_lcm, a // 2)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.284781249, "measured_runtime_v1": 0.212113862, "runtime_lift": 1.3425866952, "key": ["s703991862", "s702868581"]} {"user_id": "u391731808", "problem_id": "p03634", "language": "python", "submission_id_v0": "s145761901", "submission_id_v1": "s949294302", "cpu_time_v0": 1740, "cpu_time_v1": 1056, "memory_v0": 98856, "memory_v1": 98636, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 39.31, "input": "import heapq\n\n\n\nN = int(input())\n\nabc = [list(map(int,input().split())) for _ in range(N-1)]\n\nQ,K = list(map(int,input().split()))\n\nxy = [list(map(int,input().split())) for _ in range(Q)]\n\n\n\nconnect = [[] for _ in range(N)]\n\nINFTY = 10**15\n\nfor a,b,c in abc:\n\n connect[a-1].append([b-1,c])\n\n connect[b-1].append([a-1,c])\n\n\n\ncost = [[INFTY,False] for _ in range(N)]\n\ncost[K-1][0] = 0\n\nq = [(0,K-1)]\n\nwhile q:\n\n _,i = heapq.heappop(q)\n\n if cost[i][1]:\n\n continue\n\n cost[i][1] = True\n\n ci0 = cost[i][0]\n\n for j,c in connect[i]:\n\n if cost[j][1]:\n\n continue\n\n tmp_cost = ci0+c\n\n if tmp_cost < cost[j][0]:\n\n cost[j][0] = tmp_cost\n\n heapq.heappush(q,(tmp_cost,j))\n\n\n\nfor x,y in xy:\n\n print((cost[x-1][0] + cost[y-1][0]))", "target": "N = int(input())\n\nABC = [list(map(int,input().split())) for _ in [0]*(N-1)]\n\nQ,K = list(map(int,input().split()))\n\nXY = [list(map(int,input().split())) for _ in [0]*Q]\n\n\n\nE = [{} for _ in [0]*N]\n\nfor a,b,c in ABC:\n\n E[a-1][b-1] = c\n\n E[b-1][a-1] = c\n\n\n\ndef dist_dfs_tree(N,E,start):\n\n d = [-1]*N\n\n d[start] = 0\n\n q = [start]\n\n while q:\n\n i = q.pop()\n\n ci = d[i]\n\n for j,cj in list(E[i].items()):\n\n if d[j] !=-1:continue\n\n d[j] = ci+cj\n\n q.append(j)\n\n return d\n\n\n\nd = dist_dfs_tree(N,E,K-1)\n\nfor x,y in XY:\n\n print((d[x-1]+d[y-1]))", "code_v0_loc": 32, "code_v1_loc": 26, "code_v0_num_chars": 797, "code_v1_num_chars": 594, "code_v0_no_empty_lines": "import heapq\n\nN = int(input())\nabc = [list(map(int, input().split())) for _ in range(N - 1)]\nQ, K = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for _ in range(Q)]\nconnect = [[] for _ in range(N)]\nINFTY = 10**15\nfor a, b, c in abc:\n connect[a - 1].append([b - 1, c])\n connect[b - 1].append([a - 1, c])\ncost = [[INFTY, False] for _ in range(N)]\ncost[K - 1][0] = 0\nq = [(0, K - 1)]\nwhile q:\n _, i = heapq.heappop(q)\n if cost[i][1]:\n continue\n cost[i][1] = True\n ci0 = cost[i][0]\n for j, c in connect[i]:\n if cost[j][1]:\n continue\n tmp_cost = ci0 + c\n if tmp_cost < cost[j][0]:\n cost[j][0] = tmp_cost\n heapq.heappush(q, (tmp_cost, j))\nfor x, y in xy:\n print((cost[x - 1][0] + cost[y - 1][0]))\n", "code_v1_no_empty_lines": "N = int(input())\nABC = [list(map(int, input().split())) for _ in [0] * (N - 1)]\nQ, K = list(map(int, input().split()))\nXY = [list(map(int, input().split())) for _ in [0] * Q]\nE = [{} for _ in [0] * N]\nfor a, b, c in ABC:\n E[a - 1][b - 1] = c\n E[b - 1][a - 1] = c\n\n\ndef dist_dfs_tree(N, E, start):\n d = [-1] * N\n d[start] = 0\n q = [start]\n while q:\n i = q.pop()\n ci = d[i]\n for j, cj in list(E[i].items()):\n if d[j] != -1:\n continue\n d[j] = ci + cj\n q.append(j)\n return d\n\n\nd = dist_dfs_tree(N, E, K - 1)\nfor x, y in XY:\n print((d[x - 1] + d[y - 1]))\n", "code_same": false, "relative_loc_diff_percent": 18.75, "diff": ["-import heapq", "+N = int(input())", "+ABC = [list(map(int, input().split())) for _ in [0] * (N - 1)]", "+Q, K = list(map(int, input().split()))", "+XY = [list(map(int, input().split())) for _ in [0] * Q]", "+E = [{} for _ in [0] * N]", "+for a, b, c in ABC:", "+ E[a - 1][b - 1] = c", "+ E[b - 1][a - 1] = c", "-N = int(input())", "-abc = [list(map(int, input().split())) for _ in range(N - 1)]", "-Q, K = list(map(int, input().split()))", "-xy = [list(map(int, input().split())) for _ in range(Q)]", "-connect = [[] for _ in range(N)]", "-INFTY = 10**15", "-for a, b, c in abc:", "- connect[a - 1].append([b - 1, c])", "- connect[b - 1].append([a - 1, c])", "-cost = [[INFTY, False] for _ in range(N)]", "-cost[K - 1][0] = 0", "-q = [(0, K - 1)]", "-while q:", "- _, i = heapq.heappop(q)", "- if cost[i][1]:", "- continue", "- cost[i][1] = True", "- ci0 = cost[i][0]", "- for j, c in connect[i]:", "- if cost[j][1]:", "- continue", "- tmp_cost = ci0 + c", "- if tmp_cost < cost[j][0]:", "- cost[j][0] = tmp_cost", "- heapq.heappush(q, (tmp_cost, j))", "-for x, y in xy:", "- print((cost[x - 1][0] + cost[y - 1][0]))", "+", "+def dist_dfs_tree(N, E, start):", "+ d = [-1] * N", "+ d[start] = 0", "+ q = [start]", "+ while q:", "+ i = q.pop()", "+ ci = d[i]", "+ for j, cj in list(E[i].items()):", "+ if d[j] != -1:", "+ continue", "+ d[j] = ci + cj", "+ q.append(j)", "+ return d", "+", "+", "+d = dist_dfs_tree(N, E, K - 1)", "+for x, y in XY:", "+ print((d[x - 1] + d[y - 1]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2932223577, "measured_runtime_v1": 0.2194568303, "runtime_lift": 1.3361277359, "key": ["s145761901", "s949294302"]} {"user_id": "u036104576", "problem_id": "p02814", "language": "python", "submission_id_v0": "s934732087", "submission_id_v1": "s059526149", "cpu_time_v0": 249, "cpu_time_v1": 174, "memory_v0": 14544, "memory_v1": 90620, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 30.12, "input": "import sys\n\nimport itertools\n\n# import numpy as np\n\nimport time\n\nimport math\n\n \n\nsys.setrecursionlimit(10 ** 7)\n\n \n\nfrom collections import defaultdict\n\n \n\nread = sys.stdin.buffer.read\n\nreadline = sys.stdin.buffer.readline\n\nreadlines = sys.stdin.buffer.readlines\n\n \n\n \n\nfrom functools import reduce\n\n# from math import *\n\nfrom math import *\n\nN, M = list(map(int, readline().split()))\n\nA = list(sorted([int(x) // 2 for x in readline().split()]))\n\nmin_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)\n\n \n\n# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))\n\nif not all([(min_cm // x) % 2 == 1 for x in A]):\n\n print((0))\n\n exit(0)\n\nif min_cm > M:\n\n print((0))\n\n exit(0)\n\nans = (M // min_cm + 1) // 2\n\nprint(ans)", "target": "import sys\n\nimport itertools\n\n# import numpy as np\n\nimport time\n\nimport math\n\nimport heapq\n\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10 ** 7)\n\n \n\nINF = 10 ** 9 + 7\n\nread = sys.stdin.buffer.read\n\nreadline = sys.stdin.buffer.readline\n\nreadlines = sys.stdin.buffer.readlines\n\n\n\n# map(int, input().split())\n\n\n\nN, M = list(map(int, input().split()))\n\nA = list([int(x) // 2 for x in input().split()])\n\n\n\ndef f(n):\n\n res = 0\n\n while n % 2 == 0:\n\n n //= 2\n\n res += 1\n\n return res\n\n\n\ndef gcd(a, b):\n\n if b == 0:\n\n return a\n\n return gcd(b, a % b)\n\n\n\nx = f(A[0])\n\nfor a in A:\n\n y = f(a)\n\n if y != x:\n\n print((0))\n\n exit()\n\n\n\nlcm = A[0]\n\nfor i in range(1, N):\n\n lcm = lcm * A[i] // gcd(lcm, A[i])\n\n\n\nprint(((M // lcm + 1) // 2))", "code_v0_loc": 31, "code_v1_loc": 43, "code_v0_num_chars": 729, "code_v1_num_chars": 789, "code_v0_no_empty_lines": "import sys\nimport itertools\n\n# import numpy as np\nimport time\nimport math\n\nsys.setrecursionlimit(10**7)\nfrom collections import defaultdict\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom functools import reduce\n\n# from math import *\nfrom math import *\n\nN, M = list(map(int, readline().split()))\nA = list(sorted([int(x) // 2 for x in readline().split()]))\nmin_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)\n# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))\nif not all([(min_cm // x) % 2 == 1 for x in A]):\n print((0))\n exit(0)\nif min_cm > M:\n print((0))\n exit(0)\nans = (M // min_cm + 1) // 2\nprint(ans)\n", "code_v1_no_empty_lines": "import sys\nimport itertools\n\n# import numpy as np\nimport time\nimport math\nimport heapq\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10**7)\nINF = 10**9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n# map(int, input().split())\nN, M = list(map(int, input().split()))\nA = list([int(x) // 2 for x in input().split()])\n\n\ndef f(n):\n res = 0\n while n % 2 == 0:\n n //= 2\n res += 1\n return res\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\n\nx = f(A[0])\nfor a in A:\n y = f(a)\n if y != x:\n print((0))\n exit()\nlcm = A[0]\nfor i in range(1, N):\n lcm = lcm * A[i] // gcd(lcm, A[i])\nprint(((M // lcm + 1) // 2))\n", "code_same": false, "relative_loc_diff_percent": 27.9069767442, "diff": ["+import heapq", "+from collections import defaultdict", "-from collections import defaultdict", "-", "+INF = 10**9 + 7", "-from functools import reduce", "+# map(int, input().split())", "+N, M = list(map(int, input().split()))", "+A = list([int(x) // 2 for x in input().split()])", "-# from math import *", "-from math import *", "-N, M = list(map(int, readline().split()))", "-A = list(sorted([int(x) // 2 for x in readline().split()]))", "-min_cm = reduce(lambda a, b: (a * b) // gcd(a, b), A)", "-# print(all(map(lambda x: (min_cm // x) % 2 == 1, A)))", "-if not all([(min_cm // x) % 2 == 1 for x in A]):", "- print((0))", "- exit(0)", "-if min_cm > M:", "- print((0))", "- exit(0)", "-ans = (M // min_cm + 1) // 2", "-print(ans)", "+def f(n):", "+ res = 0", "+ while n % 2 == 0:", "+ n //= 2", "+ res += 1", "+ return res", "+", "+", "+def gcd(a, b):", "+ if b == 0:", "+ return a", "+ return gcd(b, a % b)", "+", "+", "+x = f(A[0])", "+for a in A:", "+ y = f(a)", "+ if y != x:", "+ print((0))", "+ exit()", "+lcm = A[0]", "+for i in range(1, N):", "+ lcm = lcm * A[i] // gcd(lcm, A[i])", "+print(((M // lcm + 1) // 2))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.414138025, "measured_runtime_v1": 0.277947119, "runtime_lift": 1.4899885508, "key": ["s934732087", "s059526149"]} {"user_id": "u970197315", "problem_id": "p02814", "language": "python", "submission_id_v0": "s991587805", "submission_id_v1": "s856136819", "cpu_time_v0": 253, "cpu_time_v1": 206, "memory_v0": 16276, "memory_v1": 20232, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 18.58, "input": "# ABC150 D\n\nsi = lambda: input()\n\nni = lambda: int(input())\n\nnm = lambda: list(map(int, input().split()))\n\nnl = lambda: list(map(int, input().split()))\n\nfrom math import gcd\n\nfrom math import ceil\n\ndef lcm(x, y):\n\n return (x * y) // gcd(x, y)\n\nn,m=nm()\n\na=nl()\n\nans=0\n\na=[x//2 for x in a] \n\n\n\nlcm_v=a[0]\n\nfor i in range(n):\n\n lcm_v=lcm(lcm_v,a[i])\n\nok_flg=[(lcm_v//i)%2==1 for i in a]\n\nif all(ok_flg):\n\n ans=((m//lcm_v)+1)//2\n\nprint(ans)\n\n\n", "target": "from math import gcd, ceil\n\n\n\n\n\ndef lcm(a, b):\n\n return (a*b)//gcd(a, b)\n\n\n\n\n\nn, m = list(map(int, input().split()))\n\na = list(map(int, input().split()))\n\n\n\nfor i in range(n):\n\n a[i] = a[i]//2\n\n\n\nlcm_v = a[0]\n\nfor i in range(1, n):\n\n lcm_v = lcm(lcm_v, a[i])\n\n\n\nok = True\n\nfor aa in a:\n\n if (lcm_v//aa) % 2 != 1:\n\n ok = False\n\n break\n\nans = 0\n\nif ok:\n\n ans = ((m//lcm_v)+1)//2\n\nprint(ans)\n", "code_v0_loc": 22, "code_v1_loc": 26, "code_v0_num_chars": 448, "code_v1_num_chars": 412, "code_v0_no_empty_lines": "# ABC150 D\nsi = lambda: input()\nni = lambda: int(input())\nnm = lambda: list(map(int, input().split()))\nnl = lambda: list(map(int, input().split()))\nfrom math import gcd\nfrom math import ceil\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\nn, m = nm()\na = nl()\nans = 0\na = [x // 2 for x in a]\nlcm_v = a[0]\nfor i in range(n):\n lcm_v = lcm(lcm_v, a[i])\nok_flg = [(lcm_v // i) % 2 == 1 for i in a]\nif all(ok_flg):\n ans = ((m // lcm_v) + 1) // 2\nprint(ans)\n", "code_v1_no_empty_lines": "from math import gcd, ceil\n\n\ndef lcm(a, b):\n return (a * b) // gcd(a, b)\n\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\nfor i in range(n):\n a[i] = a[i] // 2\nlcm_v = a[0]\nfor i in range(1, n):\n lcm_v = lcm(lcm_v, a[i])\nok = True\nfor aa in a:\n if (lcm_v // aa) % 2 != 1:\n ok = False\n break\nans = 0\nif ok:\n ans = ((m // lcm_v) + 1) // 2\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 15.3846153846, "diff": ["-# ABC150 D", "-si = lambda: input()", "-ni = lambda: int(input())", "-nm = lambda: list(map(int, input().split()))", "-nl = lambda: list(map(int, input().split()))", "-from math import gcd", "-from math import ceil", "+from math import gcd, ceil", "-def lcm(x, y):", "- return (x * y) // gcd(x, y)", "+def lcm(a, b):", "+ return (a * b) // gcd(a, b)", "-n, m = nm()", "-a = nl()", "+n, m = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "+for i in range(n):", "+ a[i] = a[i] // 2", "+lcm_v = a[0]", "+for i in range(1, n):", "+ lcm_v = lcm(lcm_v, a[i])", "+ok = True", "+for aa in a:", "+ if (lcm_v // aa) % 2 != 1:", "+ ok = False", "+ break", "-a = [x // 2 for x in a]", "-lcm_v = a[0]", "-for i in range(n):", "- lcm_v = lcm(lcm_v, a[i])", "-ok_flg = [(lcm_v // i) % 2 == 1 for i in a]", "-if all(ok_flg):", "+if ok:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4063324592, "measured_runtime_v1": 0.2545481203, "runtime_lift": 1.5962893726, "key": ["s991587805", "s856136819"]} {"user_id": "u400765446", "problem_id": "p02412", "language": "python", "submission_id_v0": "s921182397", "submission_id_v1": "s148735991", "cpu_time_v0": 320, "cpu_time_v1": 20, "memory_v0": 5600, "memory_v1": 5600, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 93.75, "input": "def main():\n\n\n\n while True:\n\n n, x = tuple(map(int, input().split()))\n\n pattern = 0\n\n\n\n if n == x == 0:\n\n break\n\n else:\n\n for a in range(1, n+1):\n\n for b in range(1, a):\n\n for c in range(1, b):\n\n pattern += 1 if a + b + c == x and a > b > c else 0\n\n print(pattern)\n\n \n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "def divide_two(c, z):\n\n min_b = z // 2 + 1\n\n max_b = min(c-1, z-1)\n\n return max(max_b-min_b+1, 0)\n\n \n\n\n\nnum_set = []\n\ncnt = 0\n\nwhile True:\n\n n, x = list(map(int, input().split()))\n\n if (n, x) == (0, 0):\n\n break\n\n else:\n\n num_set.append((n, x))\n\n cnt += 1\n\n\n\nfor i in range(cnt):\n\n num_count = 0\n\n (n, x) = num_set[i]\n\n for c in range(x//3, n+1):\n\n num_count += divide_two(c, x-c)\n\n print(num_count)\n", "code_v0_loc": 18, "code_v1_loc": 22, "code_v0_num_chars": 458, "code_v1_num_chars": 454, "code_v0_no_empty_lines": "def main():\n while True:\n n, x = tuple(map(int, input().split()))\n pattern = 0\n if n == x == 0:\n break\n else:\n for a in range(1, n + 1):\n for b in range(1, a):\n for c in range(1, b):\n pattern += 1 if a + b + c == x and a > b > c else 0\n print(pattern)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def divide_two(c, z):\n min_b = z // 2 + 1\n max_b = min(c - 1, z - 1)\n return max(max_b - min_b + 1, 0)\n\n\nnum_set = []\ncnt = 0\nwhile True:\n n, x = list(map(int, input().split()))\n if (n, x) == (0, 0):\n break\n else:\n num_set.append((n, x))\n cnt += 1\nfor i in range(cnt):\n num_count = 0\n (n, x) = num_set[i]\n for c in range(x // 3, n + 1):\n num_count += divide_two(c, x - c)\n print(num_count)\n", "code_same": false, "relative_loc_diff_percent": 18.1818181818, "diff": ["-def main():", "- while True:", "- n, x = tuple(map(int, input().split()))", "- pattern = 0", "- if n == x == 0:", "- break", "- else:", "- for a in range(1, n + 1):", "- for b in range(1, a):", "- for c in range(1, b):", "- pattern += 1 if a + b + c == x and a > b > c else 0", "- print(pattern)", "+def divide_two(c, z):", "+ min_b = z // 2 + 1", "+ max_b = min(c - 1, z - 1)", "+ return max(max_b - min_b + 1, 0)", "-if __name__ == \"__main__\":", "- main()", "+num_set = []", "+cnt = 0", "+while True:", "+ n, x = list(map(int, input().split()))", "+ if (n, x) == (0, 0):", "+ break", "+ else:", "+ num_set.append((n, x))", "+ cnt += 1", "+for i in range(cnt):", "+ num_count = 0", "+ (n, x) = num_set[i]", "+ for c in range(x // 3, n + 1):", "+ num_count += divide_two(c, x - c)", "+ print(num_count)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2920441294, "measured_runtime_v1": 0.2327923727, "runtime_lift": 1.2545261942, "key": ["s921182397", "s148735991"]} {"user_id": "u634461820", "problem_id": "p02863", "language": "python", "submission_id_v0": "s061535189", "submission_id_v1": "s586045080", "cpu_time_v0": 1058, "cpu_time_v1": 461, "memory_v0": 183896, "memory_v1": 117976, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 56.43, "input": "import sys\n\nfrom operator import itemgetter\n\nfrom heapq import heapify, heappop, heappush\n\nMAX_INT = int(10e15)\n\nMIN_INT = -MAX_INT\n\nmod = 1000000007\n\nsys.setrecursionlimit(1000000)\n\ndef IL(): return list(map(int,input().split()))\n\ndef SL(): return input().split()\n\ndef I(): return int(sys.stdin.readline())\n\ndef S(): return input()\n\n\n\nN, T = IL()\n\nab = [IL() for i in range(N)]\n\nab.sort(key=itemgetter(0))\n\n#print(ab)\n\n\n\ndp = [[0]*(T+1+3000+1) for _ in range(N+1)]\n\nans = 0\n\nfor i in range(N):\n\n for j in range(T+1+3000+1):\n\n time, deli = ab[i]\n\n if 0 <= j-time < T:\n\n dp[i + 1][j] = max(dp[i][j], dp[i][j - time] + deli)\n\n else:\n\n dp[i + 1][j] = dp[i][j]\n\n ans = max(ans, dp[i + 1][j])\n\nprint(ans)\n\n\n\n#print(dp)\n", "target": "import sys\n\nfrom collections import deque\n\nMAX_INT = int(10e10)\n\nMIN_INT = -MAX_INT\n\nmod = 1000000007\n\nsys.setrecursionlimit(1000000)\n\ndef IL(): return list(map(int,input().split()))\n\ndef SL(): return input().split()\n\ndef I(): return int(sys.stdin.readline())\n\ndef S(): return input()\n\n\n\nN,T = IL()\n\nab = [IL() for i in range(N)]\n\nab.sort()\n\n\n\nans = 0\n\ndp = [[0]*T for i in range(N+1)]\n\nfor i in range(1,N+1):\n\n a,b = ab[i-1]\n\n for j in range(T):\n\n if 0 <= j-a < T:\n\n dp[i][j] = max(dp[i-1][j], dp[i-1][j-a] + b)\n\n else:\n\n dp[i][j] = dp[i-1][j]\n\n else:\n\n ans = max(ans, dp[i-1][-1] + b)\n\nprint(ans)", "code_v0_loc": 30, "code_v1_loc": 27, "code_v0_num_chars": 737, "code_v1_num_chars": 620, "code_v0_no_empty_lines": "import sys\nfrom operator import itemgetter\nfrom heapq import heapify, heappop, heappush\n\nMAX_INT = int(10e15)\nMIN_INT = -MAX_INT\nmod = 1000000007\nsys.setrecursionlimit(1000000)\n\n\ndef IL():\n return list(map(int, input().split()))\n\n\ndef SL():\n return input().split()\n\n\ndef I():\n return int(sys.stdin.readline())\n\n\ndef S():\n return input()\n\n\nN, T = IL()\nab = [IL() for i in range(N)]\nab.sort(key=itemgetter(0))\n# print(ab)\ndp = [[0] * (T + 1 + 3000 + 1) for _ in range(N + 1)]\nans = 0\nfor i in range(N):\n for j in range(T + 1 + 3000 + 1):\n time, deli = ab[i]\n if 0 <= j - time < T:\n dp[i + 1][j] = max(dp[i][j], dp[i][j - time] + deli)\n else:\n dp[i + 1][j] = dp[i][j]\n ans = max(ans, dp[i + 1][j])\nprint(ans)\n# print(dp)\n", "code_v1_no_empty_lines": "import sys\nfrom collections import deque\n\nMAX_INT = int(10e10)\nMIN_INT = -MAX_INT\nmod = 1000000007\nsys.setrecursionlimit(1000000)\n\n\ndef IL():\n return list(map(int, input().split()))\n\n\ndef SL():\n return input().split()\n\n\ndef I():\n return int(sys.stdin.readline())\n\n\ndef S():\n return input()\n\n\nN, T = IL()\nab = [IL() for i in range(N)]\nab.sort()\nans = 0\ndp = [[0] * T for i in range(N + 1)]\nfor i in range(1, N + 1):\n a, b = ab[i - 1]\n for j in range(T):\n if 0 <= j - a < T:\n dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a] + b)\n else:\n dp[i][j] = dp[i - 1][j]\n else:\n ans = max(ans, dp[i - 1][-1] + b)\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 10.0, "diff": ["-from operator import itemgetter", "-from heapq import heapify, heappop, heappush", "+from collections import deque", "-MAX_INT = int(10e15)", "+MAX_INT = int(10e10)", "-ab.sort(key=itemgetter(0))", "-# print(ab)", "-dp = [[0] * (T + 1 + 3000 + 1) for _ in range(N + 1)]", "+ab.sort()", "-for i in range(N):", "- for j in range(T + 1 + 3000 + 1):", "- time, deli = ab[i]", "- if 0 <= j - time < T:", "- dp[i + 1][j] = max(dp[i][j], dp[i][j - time] + deli)", "+dp = [[0] * T for i in range(N + 1)]", "+for i in range(1, N + 1):", "+ a, b = ab[i - 1]", "+ for j in range(T):", "+ if 0 <= j - a < T:", "+ dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a] + b)", "- dp[i + 1][j] = dp[i][j]", "- ans = max(ans, dp[i + 1][j])", "+ dp[i][j] = dp[i - 1][j]", "+ else:", "+ ans = max(ans, dp[i - 1][-1] + b)", "-# print(dp)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4860900669, "measured_runtime_v1": 0.3545958745, "runtime_lift": 1.3708283197, "key": ["s061535189", "s586045080"]} {"user_id": "u893063840", "problem_id": "p03801", "language": "python", "submission_id_v0": "s790222372", "submission_id_v1": "s964537161", "cpu_time_v0": 316, "cpu_time_v1": 278, "memory_v0": 40396, "memory_v1": 31800, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 12.03, "input": "n = int(input())\n\na = list(map(int, input().split()))\n\n\n\ntmp = [[e, n - i] for i, e in enumerate(a)]\n\ntmp.sort(reverse=True)\n\n\n\naa = [[e, n - i] for e, i in tmp] + [[0, -1]]\n\n\n\nv_prev, i_prev = aa[0]\n\ni = 0\n\nans = [0] * n\n\nsm = 0\n\nwhile i < n:\n\n while aa[i][1] >= i_prev:\n\n sm += aa[i][0]\n\n i += 1\n\n\n\n ans[i_prev] += sm - aa[i][0] * i\n\n sm = aa[i][0] * i\n\n v_prev, i_prev = aa[i]\n\n\n\nprint(*ans, sep=\"\\n\")\n", "target": "from bisect import bisect_right\n\n\n\nn = int(input())\n\na = list(map(int, input().split()))\n\n\n\nli = [[0, -1]]\n\nfor i, e in enumerate(a):\n\n if e > li[-1][0]:\n\n li.append([e, i])\n\n\n\nli = li[::-1]\n\n\n\na.sort()\n\nacc = [0] * (n + 1)\n\nfor i in range(n - 1, -1, -1):\n\n acc[i] = acc[i+1] + a[i]\n\n\n\nans = [0] * n\n\nsub = 0\n\nans_prev = 0\n\nfor (ep, ip), (e, i) in zip(li, li[1:]):\n\n j = bisect_right(a, e)\n\n ans[ip] = acc[j] - e * (n - j)\n\n\n\ni_prev = 0\n\nfor i in range(1, n):\n\n if ans[i]:\n\n ans[i_prev] -= ans[i]\n\n i_prev = i\n\n\n\nprint(*ans, sep=\"\\n\")\n", "code_v0_loc": 22, "code_v1_loc": 31, "code_v0_num_chars": 431, "code_v1_num_chars": 571, "code_v0_no_empty_lines": "n = int(input())\na = list(map(int, input().split()))\ntmp = [[e, n - i] for i, e in enumerate(a)]\ntmp.sort(reverse=True)\naa = [[e, n - i] for e, i in tmp] + [[0, -1]]\nv_prev, i_prev = aa[0]\ni = 0\nans = [0] * n\nsm = 0\nwhile i < n:\n while aa[i][1] >= i_prev:\n sm += aa[i][0]\n i += 1\n ans[i_prev] += sm - aa[i][0] * i\n sm = aa[i][0] * i\n v_prev, i_prev = aa[i]\nprint(*ans, sep=\"\\n\")\n", "code_v1_no_empty_lines": "from bisect import bisect_right\n\nn = int(input())\na = list(map(int, input().split()))\nli = [[0, -1]]\nfor i, e in enumerate(a):\n if e > li[-1][0]:\n li.append([e, i])\nli = li[::-1]\na.sort()\nacc = [0] * (n + 1)\nfor i in range(n - 1, -1, -1):\n acc[i] = acc[i + 1] + a[i]\nans = [0] * n\nsub = 0\nans_prev = 0\nfor (ep, ip), (e, i) in zip(li, li[1:]):\n j = bisect_right(a, e)\n ans[ip] = acc[j] - e * (n - j)\ni_prev = 0\nfor i in range(1, n):\n if ans[i]:\n ans[i_prev] -= ans[i]\n i_prev = i\nprint(*ans, sep=\"\\n\")\n", "code_same": false, "relative_loc_diff_percent": 29.0322580645, "diff": ["+from bisect import bisect_right", "+", "-tmp = [[e, n - i] for i, e in enumerate(a)]", "-tmp.sort(reverse=True)", "-aa = [[e, n - i] for e, i in tmp] + [[0, -1]]", "-v_prev, i_prev = aa[0]", "-i = 0", "+li = [[0, -1]]", "+for i, e in enumerate(a):", "+ if e > li[-1][0]:", "+ li.append([e, i])", "+li = li[::-1]", "+a.sort()", "+acc = [0] * (n + 1)", "+for i in range(n - 1, -1, -1):", "+ acc[i] = acc[i + 1] + a[i]", "-sm = 0", "-while i < n:", "- while aa[i][1] >= i_prev:", "- sm += aa[i][0]", "- i += 1", "- ans[i_prev] += sm - aa[i][0] * i", "- sm = aa[i][0] * i", "- v_prev, i_prev = aa[i]", "+sub = 0", "+ans_prev = 0", "+for (ep, ip), (e, i) in zip(li, li[1:]):", "+ j = bisect_right(a, e)", "+ ans[ip] = acc[j] - e * (n - j)", "+i_prev = 0", "+for i in range(1, n):", "+ if ans[i]:", "+ ans[i_prev] -= ans[i]", "+ i_prev = i"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2510323788, "measured_runtime_v1": 0.1409289612, "runtime_lift": 1.7812689216, "key": ["s790222372", "s964537161"]} {"user_id": "u970197315", "problem_id": "p03013", "language": "python", "submission_id_v0": "s479618893", "submission_id_v1": "s899240371", "cpu_time_v0": 212, "cpu_time_v1": 187, "memory_v0": 9612, "memory_v1": 7848, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 11.79, "input": "N, M = list(map(int, input().split()))\n\nA_ = [int(input()) for _ in range(M)]\n\nA = [0] * (N+3)\n\nfor a in A_:\n\n A[a] = 1\n\ndp = [0] * (N+3)\n\ndp[0] = 1\n\n\n\nmod = 10**9+7\n\n\n\nfor i in range(1, N+1):\n\n if A[i-1] == 0:\n\n dp[i] += dp[i-1]\n\n if A[i-2] == 0:\n\n dp[i] += dp[i-2]\n\n dp[i] %= mod\n\nprint((dp[N]))", "target": "n,m=list(map(int,input().split()))\n\ndp=[0]*(n+3)\n\na=[int(input()) for i in range(m)]\n\nmod=10**9+7\n\nfor i in range(m):\n\n dp[a[i]]=-1\n\n\n\ndp[0]=1\n\nif dp[1]!=-1:\n\n dp[1]+=dp[0]\n\n\n\nfor i in range(n+1):\n\n if dp[i+2]==-1:\n\n continue\n\n if dp[i]!=-1:\n\n dp[i+2]+=dp[i]\n\n if dp[i+1]!=-1:\n\n dp[i+2]+=dp[i+1]\n\n dp[i+2]%=mod\n\nprint((dp[n]%mod))", "code_v0_loc": 17, "code_v1_loc": 20, "code_v0_num_chars": 315, "code_v1_num_chars": 361, "code_v0_no_empty_lines": "N, M = list(map(int, input().split()))\nA_ = [int(input()) for _ in range(M)]\nA = [0] * (N + 3)\nfor a in A_:\n A[a] = 1\ndp = [0] * (N + 3)\ndp[0] = 1\nmod = 10**9 + 7\nfor i in range(1, N + 1):\n if A[i - 1] == 0:\n dp[i] += dp[i - 1]\n if A[i - 2] == 0:\n dp[i] += dp[i - 2]\n dp[i] %= mod\nprint((dp[N]))\n", "code_v1_no_empty_lines": "n, m = list(map(int, input().split()))\ndp = [0] * (n + 3)\na = [int(input()) for i in range(m)]\nmod = 10**9 + 7\nfor i in range(m):\n dp[a[i]] = -1\ndp[0] = 1\nif dp[1] != -1:\n dp[1] += dp[0]\nfor i in range(n + 1):\n if dp[i + 2] == -1:\n continue\n if dp[i] != -1:\n dp[i + 2] += dp[i]\n if dp[i + 1] != -1:\n dp[i + 2] += dp[i + 1]\n dp[i + 2] %= mod\nprint((dp[n] % mod))\n", "code_same": false, "relative_loc_diff_percent": 15.0, "diff": ["-N, M = list(map(int, input().split()))", "-A_ = [int(input()) for _ in range(M)]", "-A = [0] * (N + 3)", "-for a in A_:", "- A[a] = 1", "-dp = [0] * (N + 3)", "+n, m = list(map(int, input().split()))", "+dp = [0] * (n + 3)", "+a = [int(input()) for i in range(m)]", "+mod = 10**9 + 7", "+for i in range(m):", "+ dp[a[i]] = -1", "-mod = 10**9 + 7", "-for i in range(1, N + 1):", "- if A[i - 1] == 0:", "- dp[i] += dp[i - 1]", "- if A[i - 2] == 0:", "- dp[i] += dp[i - 2]", "- dp[i] %= mod", "-print((dp[N]))", "+if dp[1] != -1:", "+ dp[1] += dp[0]", "+for i in range(n + 1):", "+ if dp[i + 2] == -1:", "+ continue", "+ if dp[i] != -1:", "+ dp[i + 2] += dp[i]", "+ if dp[i + 1] != -1:", "+ dp[i + 2] += dp[i + 1]", "+ dp[i + 2] %= mod", "+print((dp[n] % mod))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2706730585, "measured_runtime_v1": 0.2065423949, "runtime_lift": 1.3104963688, "key": ["s479618893", "s899240371"]} {"user_id": "u498487134", "problem_id": "p03038", "language": "python", "submission_id_v0": "s547925628", "submission_id_v1": "s764313725", "cpu_time_v0": 649, "cpu_time_v1": 471, "memory_v0": 68588, "memory_v1": 102672, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 27.43, "input": "import sys\n\ninput = sys.stdin.readline\n\n\n\ndef I(): return int(input())\n\ndef MI(): return list(map(int, input().split()))\n\ndef LI(): return list(map(int, input().split()))\n\n\n\ndef main():\n\n mod=10**9+7\n\n N,M=MI()\n\n A=LI()\n\n CB=[[0,0]for _ in range(M)]\n\n A.sort()\n\n for i in range(M):\n\n CB[i][1],CB[i][0]=MI()\n\n \n\n CB.sort(reverse=True)\n\n now=0\n\n \n\n for i in range(N):\n\n if CB[now][1]<=0:\n\n now+=1\n\n \n\n if now>=M:\n\n break \n\n \n\n ch=CB[now][0]\n\n if A[i]=c:\n\n heapq.heappush(A,a)\n\n break\n\n else:\n\n heapq.heappush(A,c)\n\n \n\n ans=0\n\n for i in range(N):\n\n a=heapq.heappop(A)\n\n ans+=a\n\n \n\n print(ans)\n\n\n\nmain()\n", "code_v0_loc": 37, "code_v1_loc": 42, "code_v0_num_chars": 685, "code_v1_num_chars": 804, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return list(map(int, input().split()))\n\n\ndef LI():\n return list(map(int, input().split()))\n\n\ndef main():\n mod = 10**9 + 7\n N, M = MI()\n A = LI()\n CB = [[0, 0] for _ in range(M)]\n A.sort()\n for i in range(M):\n CB[i][1], CB[i][0] = MI()\n CB.sort(reverse=True)\n now = 0\n for i in range(N):\n if CB[now][1] <= 0:\n now += 1\n if now >= M:\n break\n ch = CB[now][0]\n if A[i] < ch:\n A[i] = ch\n CB[now][1] -= 1\n else:\n break\n print((sum(A)))\n\n\nmain()\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\n\n\ndef I():\n return int(input())\n\n\ndef MI():\n return list(map(int, input().split()))\n\n\ndef LI():\n return list(map(int, input().split()))\n\n\ndef main():\n mod = 10**9 + 7\n N, M = MI()\n A = LI()\n B = [0] * M\n C = [0] * M\n for i in range(M):\n B[i], C[i] = MI()\n C, B = list(zip(*sorted(zip(C, B))))\n B = B[::-1]\n C = C[::-1]\n import heapq\n\n heapq.heapify(A)\n for i in range(M):\n b = B[i]\n c = C[i]\n for _ in range(b):\n a = heapq.heappop(A)\n if a >= c:\n heapq.heappush(A, a)\n break\n else:\n heapq.heappush(A, c)\n ans = 0\n for i in range(N):\n a = heapq.heappop(A)\n ans += a\n print(ans)\n\n\nmain()\n", "code_same": false, "relative_loc_diff_percent": 11.9047619048, "diff": ["- CB = [[0, 0] for _ in range(M)]", "- A.sort()", "+ B = [0] * M", "+ C = [0] * M", "- CB[i][1], CB[i][0] = MI()", "- CB.sort(reverse=True)", "- now = 0", "+ B[i], C[i] = MI()", "+ C, B = list(zip(*sorted(zip(C, B))))", "+ B = B[::-1]", "+ C = C[::-1]", "+ import heapq", "+", "+ heapq.heapify(A)", "+ for i in range(M):", "+ b = B[i]", "+ c = C[i]", "+ for _ in range(b):", "+ a = heapq.heappop(A)", "+ if a >= c:", "+ heapq.heappush(A, a)", "+ break", "+ else:", "+ heapq.heappush(A, c)", "+ ans = 0", "- if CB[now][1] <= 0:", "- now += 1", "- if now >= M:", "- break", "- ch = CB[now][0]", "- if A[i] < ch:", "- A[i] = ch", "- CB[now][1] -= 1", "- else:", "- break", "- print((sum(A)))", "+ a = heapq.heappop(A)", "+ ans += a", "+ print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2322117374, "measured_runtime_v1": 0.1336252203, "runtime_lift": 1.7377837571, "key": ["s547925628", "s764313725"]} {"user_id": "u396211450", "problem_id": "p03828", "language": "python", "submission_id_v0": "s749493108", "submission_id_v1": "s831049300", "cpu_time_v0": 39, "cpu_time_v1": 31, "memory_v0": 9360, "memory_v1": 9168, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 20.51, "input": "from math import factorial\n\n\n\nn = int(input())\n\nf = factorial(n)\n\n\n\nmod = 10 ** 9 + 7\n\n\n\ndef primes(n):\n\n is_prime = [True] * (n + 1)\n\n is_prime[0] = False\n\n is_prime[1] = False\n\n for i in range(2, int(n ** 0.5) + 1):\n\n if not is_prime[i]:\n\n continue\n\n for j in range(i * 2, n + 1, i):\n\n is_prime[j] = False\n\n return [i for i in range(n + 1) if is_prime[i]]\n\n\n\nans = 1\n\nfor p in primes(n):\n\n temp = 1\n\n while f % p == 0:\n\n temp += 1\n\n f //= p\n\n ans = (ans * temp) % mod\n\nprint(ans)\n", "target": "n=int(input())\n\nm=10**9+7\n\np=[1 for i in range(10000)]\n\np[0]=0\n\np[1]=0\n\nfor i in range(2,n+1):\n\n if p[i]==1:\n\n for j in range(i*i,n+1,i):\n\n p[j]=0\n\nans=1\n\nfor i in range(2,n+1):\n\n if p[i]:\n\n c=0\n\n k=i\n\n while n//k>0:\n\n c=c+(n//k)%m\n\n k=k*i\n\n ans=(ans*((c+1)%m))%m\n\nprint((ans%m))\n\n \n\n \n\n \n\n \n", "code_v0_loc": 26, "code_v1_loc": 23, "code_v0_num_chars": 556, "code_v1_num_chars": 340, "code_v0_no_empty_lines": "from math import factorial\n\nn = int(input())\nf = factorial(n)\nmod = 10**9 + 7\n\n\ndef primes(n):\n is_prime = [True] * (n + 1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5) + 1):\n if not is_prime[i]:\n continue\n for j in range(i * 2, n + 1, i):\n is_prime[j] = False\n return [i for i in range(n + 1) if is_prime[i]]\n\n\nans = 1\nfor p in primes(n):\n temp = 1\n while f % p == 0:\n temp += 1\n f //= p\n ans = (ans * temp) % mod\nprint(ans)\n", "code_v1_no_empty_lines": "n = int(input())\nm = 10**9 + 7\np = [1 for i in range(10000)]\np[0] = 0\np[1] = 0\nfor i in range(2, n + 1):\n if p[i] == 1:\n for j in range(i * i, n + 1, i):\n p[j] = 0\nans = 1\nfor i in range(2, n + 1):\n if p[i]:\n c = 0\n k = i\n while n // k > 0:\n c = c + (n // k) % m\n k = k * i\n ans = (ans * ((c + 1) % m)) % m\nprint((ans % m))\n", "code_same": false, "relative_loc_diff_percent": 11.5384615385, "diff": ["-from math import factorial", "-", "-f = factorial(n)", "-mod = 10**9 + 7", "-", "-", "-def primes(n):", "- is_prime = [True] * (n + 1)", "- is_prime[0] = False", "- is_prime[1] = False", "- for i in range(2, int(n**0.5) + 1):", "- if not is_prime[i]:", "- continue", "- for j in range(i * 2, n + 1, i):", "- is_prime[j] = False", "- return [i for i in range(n + 1) if is_prime[i]]", "-", "-", "+m = 10**9 + 7", "+p = [1 for i in range(10000)]", "+p[0] = 0", "+p[1] = 0", "+for i in range(2, n + 1):", "+ if p[i] == 1:", "+ for j in range(i * i, n + 1, i):", "+ p[j] = 0", "-for p in primes(n):", "- temp = 1", "- while f % p == 0:", "- temp += 1", "- f //= p", "- ans = (ans * temp) % mod", "-print(ans)", "+for i in range(2, n + 1):", "+ if p[i]:", "+ c = 0", "+ k = i", "+ while n // k > 0:", "+ c = c + (n // k) % m", "+ k = k * i", "+ ans = (ans * ((c + 1) % m)) % m", "+print((ans % m))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2370509479, "measured_runtime_v1": 0.0064624088, "runtime_lift": 36.6815154487, "key": ["s749493108", "s831049300"]} {"user_id": "u670180528", "problem_id": "p02937", "language": "python", "submission_id_v0": "s126195271", "submission_id_v1": "s641311638", "cpu_time_v0": 161, "cpu_time_v1": 122, "memory_v0": 12200, "memory_v1": 12072, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 24.22, "input": "from collections import defaultdict\n\nfrom bisect import bisect_left\n\n\n\ns = input()\n\nn = len(s)\n\ns = s + s\n\nt = input()\n\nif set(t) - set(s):\n\n\tprint((-1))\n\n\texit()\n\nd = defaultdict(list)\n\nfor i in range(2 * n):\n\n\td[s[i]] += [i]\n\ncur = tot = 0\n\nfor c in t:\n\n\tx = d[c][bisect_left(d[c], cur)]\n\n\tif x < n:\n\n\t\tcur = x + 1\n\n\telse:\n\n\t\tcur = x - n + 1\n\n\t\ttot += n\n\ntot += cur\n\nprint(tot)\n", "target": "from collections import defaultdict\n\nfrom bisect import bisect_left\n\n\n\n\n\ndef main():\n\n\ts = input()\n\n\tn = len(s)\n\n\ts = s + s\n\n\tt = input()\n\n\tif set(t) - set(s):\n\n\t\tprint((-1))\n\n\t\texit()\n\n\td = defaultdict(list)\n\n\tfor i in range(2 * n):\n\n\t\td[s[i]] += [i]\n\n\tcur = ncnt = 0\n\n\n\n\tfor c in t:\n\n\t\tx = d[c][bisect_left(d[c], cur)]\n\n\t\tif x < n:\n\n\t\t\tcur = x + 1\n\n\t\telse:\n\n\t\t\tcur = x - n + 1\n\n\t\t\tncnt += 1\n\n\tprint((ncnt*n + cur))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n\tmain()", "code_v0_loc": 23, "code_v1_loc": 29, "code_v0_num_chars": 378, "code_v1_num_chars": 453, "code_v0_no_empty_lines": "from collections import defaultdict\nfrom bisect import bisect_left\n\ns = input()\nn = len(s)\ns = s + s\nt = input()\nif set(t) - set(s):\n print((-1))\n exit()\nd = defaultdict(list)\nfor i in range(2 * n):\n d[s[i]] += [i]\ncur = tot = 0\nfor c in t:\n x = d[c][bisect_left(d[c], cur)]\n if x < n:\n cur = x + 1\n else:\n cur = x - n + 1\n tot += n\ntot += cur\nprint(tot)\n", "code_v1_no_empty_lines": "from collections import defaultdict\nfrom bisect import bisect_left\n\n\ndef main():\n s = input()\n n = len(s)\n s = s + s\n t = input()\n if set(t) - set(s):\n print((-1))\n exit()\n d = defaultdict(list)\n for i in range(2 * n):\n d[s[i]] += [i]\n cur = ncnt = 0\n for c in t:\n x = d[c][bisect_left(d[c], cur)]\n if x < n:\n cur = x + 1\n else:\n cur = x - n + 1\n ncnt += 1\n print((ncnt * n + cur))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 20.6896551724, "diff": ["-s = input()", "-n = len(s)", "-s = s + s", "-t = input()", "-if set(t) - set(s):", "- print((-1))", "- exit()", "-d = defaultdict(list)", "-for i in range(2 * n):", "- d[s[i]] += [i]", "-cur = tot = 0", "-for c in t:", "- x = d[c][bisect_left(d[c], cur)]", "- if x < n:", "- cur = x + 1", "- else:", "- cur = x - n + 1", "- tot += n", "-tot += cur", "-print(tot)", "+", "+def main():", "+ s = input()", "+ n = len(s)", "+ s = s + s", "+ t = input()", "+ if set(t) - set(s):", "+ print((-1))", "+ exit()", "+ d = defaultdict(list)", "+ for i in range(2 * n):", "+ d[s[i]] += [i]", "+ cur = ncnt = 0", "+ for c in t:", "+ x = d[c][bisect_left(d[c], cur)]", "+ if x < n:", "+ cur = x + 1", "+ else:", "+ cur = x - n + 1", "+ ncnt += 1", "+ print((ncnt * n + cur))", "+", "+", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2683695219, "measured_runtime_v1": 0.0063027716, "runtime_lift": 42.5796046267, "key": ["s126195271", "s641311638"]} {"user_id": "u631277801", "problem_id": "p02996", "language": "python", "submission_id_v0": "s825135097", "submission_id_v1": "s901008925", "cpu_time_v0": 649, "cpu_time_v1": 495, "memory_v0": 54192, "memory_v1": 31936, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 23.73, "input": "import sys\n\nstdin = sys.stdin\n\n\n\nsys.setrecursionlimit(10 ** 7)\n\n\n\ndef li(): return list(map(int, stdin.readline().split()))\n\ndef li_(): return [int(x) - 1 for x in stdin.readline().split()]\n\ndef lf(): return list(map(float, stdin.readline().split()))\n\ndef ls(): return stdin.readline().split()\n\ndef ns(): return stdin.readline().rstrip()\n\ndef lc(): return list(ns())\n\ndef ni(): return int(stdin.readline())\n\ndef nf(): return float(stdin.readline())\n\n\n\nn = ni()\n\nab = [list(li()) for _ in range(n)]\n\n\n\nab.sort(key=lambda x: x[1])\n\n\n\ncur = 0\n\n\n\nans = True\n\n\n\nfor ai, bi in ab:\n\n cur += ai\n\n if cur > bi:\n\n ans = False\n\n\n\nprint((\"Yes\" if ans else \"No\"))", "target": "import sys\n\nstdin = sys.stdin\n\n\n\nsys.setrecursionlimit(10 ** 7)\n\n\n\ndef li(): return list(map(int, stdin.readline().split()))\n\ndef li_(): return [int(x) - 1 for x in stdin.readline().split()]\n\ndef lf(): return list(map(float, stdin.readline().split()))\n\ndef ls(): return stdin.readline().split()\n\ndef ns(): return stdin.readline().rstrip()\n\ndef lc(): return list(ns())\n\ndef ni(): return int(stdin.readline())\n\ndef nf(): return float(stdin.readline())\n\n\n\nn = ni()\n\nab = [tuple(li()) for _ in range(n)]\n\n\n\nab.sort(key=lambda x: x[1])\n\ncur = 0\n\nok = True\n\n\n\nfor ai, bi in ab:\n\n cur += ai\n\n if cur > bi:\n\n ok = False\n\n break\n\n\n\nprint((\"Yes\" if ok else \"No\"))\n", "code_v0_loc": 29, "code_v1_loc": 28, "code_v0_num_chars": 655, "code_v1_num_chars": 665, "code_v0_no_empty_lines": "import sys\n\nstdin = sys.stdin\nsys.setrecursionlimit(10**7)\n\n\ndef li():\n return list(map(int, stdin.readline().split()))\n\n\ndef li_():\n return [int(x) - 1 for x in stdin.readline().split()]\n\n\ndef lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef ls():\n return stdin.readline().split()\n\n\ndef ns():\n return stdin.readline().rstrip()\n\n\ndef lc():\n return list(ns())\n\n\ndef ni():\n return int(stdin.readline())\n\n\ndef nf():\n return float(stdin.readline())\n\n\nn = ni()\nab = [list(li()) for _ in range(n)]\nab.sort(key=lambda x: x[1])\ncur = 0\nans = True\nfor ai, bi in ab:\n cur += ai\n if cur > bi:\n ans = False\nprint((\"Yes\" if ans else \"No\"))\n", "code_v1_no_empty_lines": "import sys\n\nstdin = sys.stdin\nsys.setrecursionlimit(10**7)\n\n\ndef li():\n return list(map(int, stdin.readline().split()))\n\n\ndef li_():\n return [int(x) - 1 for x in stdin.readline().split()]\n\n\ndef lf():\n return list(map(float, stdin.readline().split()))\n\n\ndef ls():\n return stdin.readline().split()\n\n\ndef ns():\n return stdin.readline().rstrip()\n\n\ndef lc():\n return list(ns())\n\n\ndef ni():\n return int(stdin.readline())\n\n\ndef nf():\n return float(stdin.readline())\n\n\nn = ni()\nab = [tuple(li()) for _ in range(n)]\nab.sort(key=lambda x: x[1])\ncur = 0\nok = True\nfor ai, bi in ab:\n cur += ai\n if cur > bi:\n ok = False\n break\nprint((\"Yes\" if ok else \"No\"))\n", "code_same": false, "relative_loc_diff_percent": 3.4482758621, "diff": ["-ab = [list(li()) for _ in range(n)]", "+ab = [tuple(li()) for _ in range(n)]", "-ans = True", "+ok = True", "- ans = False", "-print((\"Yes\" if ans else \"No\"))", "+ ok = False", "+ break", "+print((\"Yes\" if ok else \"No\"))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2910801413, "measured_runtime_v1": 0.1842719517, "runtime_lift": 1.5796226102, "key": ["s825135097", "s901008925"]} {"user_id": "u167751176", "problem_id": "p03078", "language": "python", "submission_id_v0": "s149883415", "submission_id_v1": "s931960732", "cpu_time_v0": 641, "cpu_time_v1": 91, "memory_v0": 97660, "memory_v1": 8708, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 85.8, "input": "def main():\n\n\tx, y, z, k = list(map(int, input().split()))\n\n\ta = list(map(int, input().split()))\n\n\tb = list(map(int, input().split()))\n\n\tc = list(map(int, input().split()))\n\n\td = [0]*x*y\n\n\tfor i in range(x):\n\n\t\tfor j in range(y):\n\n\t\t\td[i*y+j] = a[i]+b[j]\n\n\td.sort(reverse=True)\n\n\tc.sort(reverse=True)\n\n\n\n\tc_len = min(k, z)\n\n\td_len = min(k, x*y)\n\n\te = [0]*d_len*c_len\n\n\tfor i in range(d_len):\n\n\t\tfor j in range(c_len):\n\n\t\t\te[i*c_len+j] = d[i] + c[j]\n\n\te.sort(reverse=True)\n\n\tfor i in range(k):\n\n\t\tprint((e[i]))\n\n\n\n\n\nif __name__ == '__main__':\n\n main()", "target": "def main():\n\n\tx, y, z, k = list(map(int, input().split()))\n\n\ta = list(map(int, input().split()))\n\n\tb = list(map(int, input().split()))\n\n\tc = list(map(int, input().split()))\n\n\n\n\tsolve(a, b, c, x, y, z, k)\n\n\n\ndef solve(a, b, c, x, y, z, k):\n\n\ta.sort(reverse=True)\n\n\tb.sort(reverse=True)\n\n\tc.sort(reverse=True)\n\n\tstack = list()\n\n\tfor p in range(x):\n\n\t\tfor q in range(y):\n\n\t\t\tif (p+1)*(q+1) > k:\n\n\t\t\t\tbreak\n\n\t\t\tfor r in range(z):\n\n\t\t\t\tif (p+1)*(q+1)*(r+1) > k:\n\n\t\t\t\t\tbreak\n\n\t\t\t\tstack.append(a[p]+b[q]+c[r])\n\n\tstack.sort(reverse=True)\n\n\tfor i in range(k):\n\n\t\tprint((stack[i]))\n\n\n\nif __name__ == '__main__':\n\n main()", "code_v0_loc": 25, "code_v1_loc": 27, "code_v0_num_chars": 545, "code_v1_num_chars": 605, "code_v0_no_empty_lines": "def main():\n x, y, z, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n d = [0] * x * y\n for i in range(x):\n for j in range(y):\n d[i * y + j] = a[i] + b[j]\n d.sort(reverse=True)\n c.sort(reverse=True)\n c_len = min(k, z)\n d_len = min(k, x * y)\n e = [0] * d_len * c_len\n for i in range(d_len):\n for j in range(c_len):\n e[i * c_len + j] = d[i] + c[j]\n e.sort(reverse=True)\n for i in range(k):\n print((e[i]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n x, y, z, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n solve(a, b, c, x, y, z, k)\n\n\ndef solve(a, b, c, x, y, z, k):\n a.sort(reverse=True)\n b.sort(reverse=True)\n c.sort(reverse=True)\n stack = list()\n for p in range(x):\n for q in range(y):\n if (p + 1) * (q + 1) > k:\n break\n for r in range(z):\n if (p + 1) * (q + 1) * (r + 1) > k:\n break\n stack.append(a[p] + b[q] + c[r])\n stack.sort(reverse=True)\n for i in range(k):\n print((stack[i]))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 7.4074074074, "diff": ["- d = [0] * x * y", "- for i in range(x):", "- for j in range(y):", "- d[i * y + j] = a[i] + b[j]", "- d.sort(reverse=True)", "+ solve(a, b, c, x, y, z, k)", "+", "+", "+def solve(a, b, c, x, y, z, k):", "+ a.sort(reverse=True)", "+ b.sort(reverse=True)", "- c_len = min(k, z)", "- d_len = min(k, x * y)", "- e = [0] * d_len * c_len", "- for i in range(d_len):", "- for j in range(c_len):", "- e[i * c_len + j] = d[i] + c[j]", "- e.sort(reverse=True)", "+ stack = list()", "+ for p in range(x):", "+ for q in range(y):", "+ if (p + 1) * (q + 1) > k:", "+ break", "+ for r in range(z):", "+ if (p + 1) * (q + 1) * (r + 1) > k:", "+ break", "+ stack.append(a[p] + b[q] + c[r])", "+ stack.sort(reverse=True)", "- print((e[i]))", "+ print((stack[i]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3135767848, "measured_runtime_v1": 0.0401056306, "runtime_lift": 7.8187720726, "key": ["s149883415", "s931960732"]} {"user_id": "u286955577", "problem_id": "p03074", "language": "python", "submission_id_v0": "s853547546", "submission_id_v1": "s138697044", "cpu_time_v0": 74, "cpu_time_v1": 66, "memory_v0": 4596, "memory_v1": 4596, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 10.81, "input": "def solve():\n\n N, K = list(map(int, input().split()))\n\n _S = input()\n\n S = []\n\n b = _S[0]\n\n s = 0\n\n if b == '0': S.append(0)\n\n for _s in _S:\n\n if b == _s:\n\n s = s + 1\n\n else:\n\n b = _s\n\n S.append(s)\n\n s = 1\n\n S.append(s)\n\n if b == '0': S.append(0)\n\n\n\n num = min(len(S), 2 * K + 1)\n\n # n = sum(S[0:num if _S[0] == '1' else (num - 1)])\n\n n = sum(S[0:num])\n\n m = n\n\n # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):\n\n for i in range(0, len(S) - num, 2):\n\n n = n - sum(S[i:i+2])\n\n n = n + sum(S[i + num:i + num + 2])\n\n m = max(m, n)\n\n\n\n return m\n\n\n\nprint((solve()))", "target": "def solve():\n\n N, K = list(map(int, input().split()))\n\n s = input()\n\n S = []\n\n b = s[0]\n\n cnt = 0\n\n\n\n if s[0] == '0': S.append(0)\n\n for c in s:\n\n if b == c: cnt = cnt + 1\n\n else:\n\n b = c\n\n S.append(cnt)\n\n cnt = 1\n\n S.append(cnt)\n\n if s[-1] == '0': S.append(0)\n\n\n\n num = min(len(S), 2 * K + 1)\n\n part = sum(S[0:num])\n\n ans = part\n\n\n\n for i in range(0, len(S) - num, 2):\n\n part = part - sum(S[i:i+2]) + sum(S[i + num:i + num + 2])\n\n ans = max(ans, part)\n\n\n\n return ans\n\n\n\nprint((solve()))\n", "code_v0_loc": 30, "code_v1_loc": 28, "code_v0_num_chars": 616, "code_v1_num_chars": 520, "code_v0_no_empty_lines": "def solve():\n N, K = list(map(int, input().split()))\n _S = input()\n S = []\n b = _S[0]\n s = 0\n if b == \"0\":\n S.append(0)\n for _s in _S:\n if b == _s:\n s = s + 1\n else:\n b = _s\n S.append(s)\n s = 1\n S.append(s)\n if b == \"0\":\n S.append(0)\n num = min(len(S), 2 * K + 1)\n # n = sum(S[0:num if _S[0] == '1' else (num - 1)])\n n = sum(S[0:num])\n m = n\n # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):\n for i in range(0, len(S) - num, 2):\n n = n - sum(S[i : i + 2])\n n = n + sum(S[i + num : i + num + 2])\n m = max(m, n)\n return m\n\n\nprint((solve()))\n", "code_v1_no_empty_lines": "def solve():\n N, K = list(map(int, input().split()))\n s = input()\n S = []\n b = s[0]\n cnt = 0\n if s[0] == \"0\":\n S.append(0)\n for c in s:\n if b == c:\n cnt = cnt + 1\n else:\n b = c\n S.append(cnt)\n cnt = 1\n S.append(cnt)\n if s[-1] == \"0\":\n S.append(0)\n num = min(len(S), 2 * K + 1)\n part = sum(S[0:num])\n ans = part\n for i in range(0, len(S) - num, 2):\n part = part - sum(S[i : i + 2]) + sum(S[i + num : i + num + 2])\n ans = max(ans, part)\n return ans\n\n\nprint((solve()))\n", "code_same": false, "relative_loc_diff_percent": 6.6666666667, "diff": ["- _S = input()", "+ s = input()", "- b = _S[0]", "- s = 0", "- if b == \"0\":", "+ b = s[0]", "+ cnt = 0", "+ if s[0] == \"0\":", "- for _s in _S:", "- if b == _s:", "- s = s + 1", "+ for c in s:", "+ if b == c:", "+ cnt = cnt + 1", "- b = _s", "- S.append(s)", "- s = 1", "- S.append(s)", "- if b == \"0\":", "+ b = c", "+ S.append(cnt)", "+ cnt = 1", "+ S.append(cnt)", "+ if s[-1] == \"0\":", "- # n = sum(S[0:num if _S[0] == '1' else (num - 1)])", "- n = sum(S[0:num])", "- m = n", "- # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):", "+ part = sum(S[0:num])", "+ ans = part", "- n = n - sum(S[i : i + 2])", "- n = n + sum(S[i + num : i + num + 2])", "- m = max(m, n)", "- return m", "+ part = part - sum(S[i : i + 2]) + sum(S[i + num : i + num + 2])", "+ ans = max(ans, part)", "+ return ans"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3473945413, "measured_runtime_v1": 0.2136866565, "runtime_lift": 1.625719392, "key": ["s853547546", "s138697044"]} {"user_id": "u575431498", "problem_id": "p03828", "language": "python", "submission_id_v0": "s058426510", "submission_id_v1": "s587454237", "cpu_time_v0": 73, "cpu_time_v1": 18, "memory_v0": 3572, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 75.34, "input": "from functools import reduce\n\nN = int(input())\n\n\n\nprime_table = [1] * (N+1)\n\n\n\nfor x in range(2, N+1):\n\n for t in range(2, x+1):\n\n while x % t == 0:\n\n prime_table[t] += 1\n\n x //= t\n\nprint((reduce(lambda x, y: x * y % (int(1e9) + 7), prime_table)))", "target": "def prime_factorize(n):\n\n while n % 2 == 0:\n\n a[2] += 1\n\n n //= 2\n\n f = 3\n\n while f * f <= n:\n\n if n % f == 0:\n\n a[f] += 1\n\n n //= f\n\n else:\n\n f += 2\n\n if n != 1:\n\n a[n] += 1\n\n\n\nN = int(input())\n\na = [0]*(N+1)\n\nfor i in range(2, N+1):\n\n prime_factorize(i)\n\nans = 1\n\nfor i in a:\n\n if i > 0:\n\n ans *= (i+1)\n\nbig = 10**9 + 7\n\nprint((ans % big))", "code_v0_loc": 11, "code_v1_loc": 24, "code_v0_num_chars": 277, "code_v1_num_chars": 432, "code_v0_no_empty_lines": "from functools import reduce\n\nN = int(input())\nprime_table = [1] * (N + 1)\nfor x in range(2, N + 1):\n for t in range(2, x + 1):\n while x % t == 0:\n prime_table[t] += 1\n x //= t\nprint((reduce(lambda x, y: x * y % (int(1e9) + 7), prime_table)))\n", "code_v1_no_empty_lines": "def prime_factorize(n):\n while n % 2 == 0:\n a[2] += 1\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a[f] += 1\n n //= f\n else:\n f += 2\n if n != 1:\n a[n] += 1\n\n\nN = int(input())\na = [0] * (N + 1)\nfor i in range(2, N + 1):\n prime_factorize(i)\nans = 1\nfor i in a:\n if i > 0:\n ans *= i + 1\nbig = 10**9 + 7\nprint((ans % big))\n", "code_same": false, "relative_loc_diff_percent": 54.1666666667, "diff": ["-from functools import reduce", "+def prime_factorize(n):", "+ while n % 2 == 0:", "+ a[2] += 1", "+ n //= 2", "+ f = 3", "+ while f * f <= n:", "+ if n % f == 0:", "+ a[f] += 1", "+ n //= f", "+ else:", "+ f += 2", "+ if n != 1:", "+ a[n] += 1", "+", "-prime_table = [1] * (N + 1)", "-for x in range(2, N + 1):", "- for t in range(2, x + 1):", "- while x % t == 0:", "- prime_table[t] += 1", "- x //= t", "-print((reduce(lambda x, y: x * y % (int(1e9) + 7), prime_table)))", "+a = [0] * (N + 1)", "+for i in range(2, N + 1):", "+ prime_factorize(i)", "+ans = 1", "+for i in a:", "+ if i > 0:", "+ ans *= i + 1", "+big = 10**9 + 7", "+print((ans % big))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2580870204, "measured_runtime_v1": 0.1952191839, "runtime_lift": 1.3220371851, "key": ["s058426510", "s587454237"]} {"user_id": "u190086340", "problem_id": "p03854", "language": "python", "submission_id_v0": "s952373499", "submission_id_v1": "s487524594", "cpu_time_v0": 320, "cpu_time_v1": 262, "memory_v0": 79600, "memory_v1": 58480, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 18.12, "input": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\n\n\n\n\ndef solve():\n\n S = input()\n\n # print(S, len(S))\n\n\n\n words = {0: \"dream\", 1: \"dreamer\", 2: \"erase\", 3: \"eraser\"}\n\n\n\n TABLE = [[-1 for x in range(len(S) + 1)] for y in range(len(words) + 1)]\n\n\n\n def recur(i, w):\n\n if not TABLE[w][i] == -1:\n\n return TABLE[w][i]\n\n\n\n if i >= len(S):\n\n # print(\"jey\", log)\n\n return True\n\n\n\n r1, r2, r3, r4 = False, False, False, False\n\n if S[i:i + 5] == words[0]:\n\n r1 = recur(i + 5, 0)\n\n if S[i:i + 7] == words[1]:\n\n r2 = recur(i + 7, 1)\n\n if S[i:i + 5] == words[2]:\n\n r3 = recur(i + 5, 2)\n\n if S[i:i + 6] == words[3]:\n\n r4 = recur(i + 6, 3)\n\n\n\n TABLE[w][i] = r1 or r2 or r3 or r4 or False\n\n\n\n return TABLE[w][i]\n\n\n\n ans = recur(0, 0)\n\n\n\n return ans\n\n\n\n\n\nif __name__ == '__main__':\n\n res = solve()\n\n if res:\n\n print(\"YES\")\n\n else:\n\n print(\"NO\")\n", "target": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\n\n\ndef solve():\n\n S = input()\n\n # print(S, len(S))\n\n\n\n S = S[::-1]\n\n words = (\"dream\"[::-1], \"dreamer\"[::-1], \"erase\"[::-1], \"eraser\"[::-1])\n\n\n\n def recur(i):\n\n if i >= len(S):\n\n return True\n\n\n\n for word in words:\n\n if S[i:i + len(word)] == word:\n\n if recur(i + len(word)):\n\n return True\n\n return False\n\n\n\n ans = recur(0)\n\n\n\n return ans\n\n\n\n\n\nif __name__ == '__main__':\n\n res = solve()\n\n if res:\n\n print(\"YES\")\n\n else:\n\n print(\"NO\")\n", "code_v0_loc": 45, "code_v1_loc": 31, "code_v0_num_chars": 1006, "code_v1_num_chars": 596, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**6)\n\n\ndef solve():\n S = input()\n # print(S, len(S))\n words = {0: \"dream\", 1: \"dreamer\", 2: \"erase\", 3: \"eraser\"}\n TABLE = [[-1 for x in range(len(S) + 1)] for y in range(len(words) + 1)]\n\n def recur(i, w):\n if not TABLE[w][i] == -1:\n return TABLE[w][i]\n if i >= len(S):\n # print(\"jey\", log)\n return True\n r1, r2, r3, r4 = False, False, False, False\n if S[i : i + 5] == words[0]:\n r1 = recur(i + 5, 0)\n if S[i : i + 7] == words[1]:\n r2 = recur(i + 7, 1)\n if S[i : i + 5] == words[2]:\n r3 = recur(i + 5, 2)\n if S[i : i + 6] == words[3]:\n r4 = recur(i + 6, 3)\n TABLE[w][i] = r1 or r2 or r3 or r4 or False\n return TABLE[w][i]\n\n ans = recur(0, 0)\n return ans\n\n\nif __name__ == \"__main__\":\n res = solve()\n if res:\n print(\"YES\")\n else:\n print(\"NO\")\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**6)\n\n\ndef solve():\n S = input()\n # print(S, len(S))\n S = S[::-1]\n words = (\"dream\"[::-1], \"dreamer\"[::-1], \"erase\"[::-1], \"eraser\"[::-1])\n\n def recur(i):\n if i >= len(S):\n return True\n for word in words:\n if S[i : i + len(word)] == word:\n if recur(i + len(word)):\n return True\n return False\n\n ans = recur(0)\n return ans\n\n\nif __name__ == \"__main__\":\n res = solve()\n if res:\n print(\"YES\")\n else:\n print(\"NO\")\n", "code_same": false, "relative_loc_diff_percent": 31.1111111111, "diff": ["- words = {0: \"dream\", 1: \"dreamer\", 2: \"erase\", 3: \"eraser\"}", "- TABLE = [[-1 for x in range(len(S) + 1)] for y in range(len(words) + 1)]", "+ S = S[::-1]", "+ words = (\"dream\"[::-1], \"dreamer\"[::-1], \"erase\"[::-1], \"eraser\"[::-1])", "- def recur(i, w):", "- if not TABLE[w][i] == -1:", "- return TABLE[w][i]", "+ def recur(i):", "- # print(\"jey\", log)", "- r1, r2, r3, r4 = False, False, False, False", "- if S[i : i + 5] == words[0]:", "- r1 = recur(i + 5, 0)", "- if S[i : i + 7] == words[1]:", "- r2 = recur(i + 7, 1)", "- if S[i : i + 5] == words[2]:", "- r3 = recur(i + 5, 2)", "- if S[i : i + 6] == words[3]:", "- r4 = recur(i + 6, 3)", "- TABLE[w][i] = r1 or r2 or r3 or r4 or False", "- return TABLE[w][i]", "+ for word in words:", "+ if S[i : i + len(word)] == word:", "+ if recur(i + len(word)):", "+ return True", "+ return False", "- ans = recur(0, 0)", "+ ans = recur(0)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3275957136, "measured_runtime_v1": 0.2137343092, "runtime_lift": 1.5327240387, "key": ["s952373499", "s487524594"]} {"user_id": "u787562674", "problem_id": "p03363", "language": "python", "submission_id_v0": "s520227607", "submission_id_v1": "s241017574", "cpu_time_v0": 271, "cpu_time_v1": 224, "memory_v0": 41880, "memory_v1": 41472, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 17.34, "input": "from collections import Counter\n\n\n\nN = int(input())\n\ninputs = [int(i) for i in input().split()]\n\n\n\nans = 0\n\nruisekiwa = [0] * (N+1)\n\n\n\nfor i in range(N):\n\n ruisekiwa[i+1] = ruisekiwa[i] + inputs[i]\n\n\n\nruisekiwa = ruisekiwa[1:]\n\nruisekiwa.sort()\n\ncounter_ruiseki = Counter(ruisekiwa)\n\n\n\nfor key, value in list(counter_ruiseki.items()):\n\n if key == 0 and value == 1:\n\n ans += value\n\n continue\n\n elif key == 0 and value > 1:\n\n ans += value\n\n if value > 1:\n\n ans += sum(list(range(value)))\n\n\n\nprint(ans)\n", "target": "from collections import Counter\n\nfrom itertools import accumulate\n\n\n\nN = int(input())\n\ninputs = [int(i) for i in input().split()]\n\n\n\nans = 0\n\n\n\nruisekiwa = list(accumulate(inputs))\n\nruisekiwa.sort()\n\ncounter_ruiseki = Counter(ruisekiwa)\n\n\n\nfor key, value in list(counter_ruiseki.items()):\n\n if key == 0 and value == 1:\n\n ans += value\n\n continue\n\n elif key == 0 and value > 1:\n\n ans += value\n\n if value > 1:\n\n ans += sum(list(range(value)))\n\n\n\nprint(ans)\n", "code_v0_loc": 25, "code_v1_loc": 22, "code_v0_num_chars": 534, "code_v1_num_chars": 485, "code_v0_no_empty_lines": "from collections import Counter\n\nN = int(input())\ninputs = [int(i) for i in input().split()]\nans = 0\nruisekiwa = [0] * (N + 1)\nfor i in range(N):\n ruisekiwa[i + 1] = ruisekiwa[i] + inputs[i]\nruisekiwa = ruisekiwa[1:]\nruisekiwa.sort()\ncounter_ruiseki = Counter(ruisekiwa)\nfor key, value in list(counter_ruiseki.items()):\n if key == 0 and value == 1:\n ans += value\n continue\n elif key == 0 and value > 1:\n ans += value\n if value > 1:\n ans += sum(list(range(value)))\nprint(ans)\n", "code_v1_no_empty_lines": "from collections import Counter\nfrom itertools import accumulate\n\nN = int(input())\ninputs = [int(i) for i in input().split()]\nans = 0\nruisekiwa = list(accumulate(inputs))\nruisekiwa.sort()\ncounter_ruiseki = Counter(ruisekiwa)\nfor key, value in list(counter_ruiseki.items()):\n if key == 0 and value == 1:\n ans += value\n continue\n elif key == 0 and value > 1:\n ans += value\n if value > 1:\n ans += sum(list(range(value)))\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 12.0, "diff": ["+from itertools import accumulate", "-ruisekiwa = [0] * (N + 1)", "-for i in range(N):", "- ruisekiwa[i + 1] = ruisekiwa[i] + inputs[i]", "-ruisekiwa = ruisekiwa[1:]", "+ruisekiwa = list(accumulate(inputs))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.19887093, "measured_runtime_v1": 0.1327844608, "runtime_lift": 1.4976973116, "key": ["s520227607", "s241017574"]} {"user_id": "u868701750", "problem_id": "p03457", "language": "python", "submission_id_v0": "s991338937", "submission_id_v1": "s211926413", "cpu_time_v0": 209, "cpu_time_v1": 173, "memory_v0": 27480, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 17.22, "input": "import sys\n\n_input = sys.stdin.readline\n\n\n\n\n\ndef resolve():\n\n N = int(_input())\n\n T = [list(map(int, _input().split())) for _ in range(N)]\n\n t, x, y = 0, 0, 0\n\n for next_t, next_x, next_y in T:\n\n diff_xy = abs(x - next_x) + abs(y - next_y)\n\n diff_t = next_t - t\n\n if diff_xy > diff_t or (diff_xy % 2 != diff_t % 2):\n\n print('No')\n\n exit(0)\n\n print('Yes')\n\n\n\n\n\nif __name__ == '__main__':\n\n resolve()", "target": "import sys\n\n_input = sys.stdin.readline\n\n\n\n\n\ndef resolve():\n\n N = int(_input())\n\n t, x, y = 0, 0, 0\n\n for _ in range(N):\n\n next_t, next_x, next_y = list(map(int, _input().split()))\n\n diff_xy = abs(x - next_x) + abs(y - next_y)\n\n diff_t = next_t - t\n\n if diff_xy > diff_t or (diff_xy % 2 != diff_t % 2):\n\n print('No')\n\n exit(0)\n\n print('Yes')\n\n\n\n\n\nif __name__ == '__main__':\n\n resolve()", "code_v0_loc": 19, "code_v1_loc": 19, "code_v0_num_chars": 459, "code_v1_num_chars": 444, "code_v0_no_empty_lines": "import sys\n\n_input = sys.stdin.readline\n\n\ndef resolve():\n N = int(_input())\n T = [list(map(int, _input().split())) for _ in range(N)]\n t, x, y = 0, 0, 0\n for next_t, next_x, next_y in T:\n diff_xy = abs(x - next_x) + abs(y - next_y)\n diff_t = next_t - t\n if diff_xy > diff_t or (diff_xy % 2 != diff_t % 2):\n print(\"No\")\n exit(0)\n print(\"Yes\")\n\n\nif __name__ == \"__main__\":\n resolve()\n", "code_v1_no_empty_lines": "import sys\n\n_input = sys.stdin.readline\n\n\ndef resolve():\n N = int(_input())\n t, x, y = 0, 0, 0\n for _ in range(N):\n next_t, next_x, next_y = list(map(int, _input().split()))\n diff_xy = abs(x - next_x) + abs(y - next_y)\n diff_t = next_t - t\n if diff_xy > diff_t or (diff_xy % 2 != diff_t % 2):\n print(\"No\")\n exit(0)\n print(\"Yes\")\n\n\nif __name__ == \"__main__\":\n resolve()\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- T = [list(map(int, _input().split())) for _ in range(N)]", "- for next_t, next_x, next_y in T:", "+ for _ in range(N):", "+ next_t, next_x, next_y = list(map(int, _input().split()))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2834033267, "measured_runtime_v1": 0.1166054926, "runtime_lift": 2.4304457743, "key": ["s991338937", "s211926413"]} {"user_id": "u761320129", "problem_id": "p03822", "language": "python", "submission_id_v0": "s508015569", "submission_id_v1": "s203932637", "cpu_time_v0": 763, "cpu_time_v1": 637, "memory_v0": 227992, "memory_v1": 123792, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 16.51, "input": "import sys\n\nsys.setrecursionlimit(202020)\n\n\n\nN = int(input())\n\nwon = [[] for i in range(N)]\n\nfor i in range(1,N):\n\n a = int(input()) - 1\n\n won[a].append(i)\n\n\n\ndef height(v):\n\n if not won[v]: return 0\n\n hs = [height(op) for op in won[v]]\n\n ret = 0\n\n for i,h in enumerate(sorted(hs)):\n\n ret = max(ret, h + len(hs) - i)\n\n return ret\n\n\n\nprint((height(0)))", "target": "import sys\n\nsys.setrecursionlimit(10**8)\n\nN = int(input())\n\nA = [int(input())-1 for i in range(N-1)]\n\nwins = [[] for _ in range(N)]\n\n\n\nfor i,a in enumerate(A):\n\n wins[a].append(i+1)\n\n\n\ndepth = [-1] * N\n\ndef dep(v):\n\n if len(wins[v])==0: return 0\n\n if depth[v] >= 0:\n\n return depth[v]\n\n ds = []\n\n for w in wins[v]:\n\n ds.append(dep(w))\n\n ds.sort(reverse=True)\n\n ret = 0\n\n for i,d in enumerate(ds):\n\n ret = max(ret, i+d+1)\n\n depth[v] = ret\n\n return ret\n\nprint((dep(0)))", "code_v0_loc": 18, "code_v1_loc": 24, "code_v0_num_chars": 377, "code_v1_num_chars": 515, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(202020)\nN = int(input())\nwon = [[] for i in range(N)]\nfor i in range(1, N):\n a = int(input()) - 1\n won[a].append(i)\n\n\ndef height(v):\n if not won[v]:\n return 0\n hs = [height(op) for op in won[v]]\n ret = 0\n for i, h in enumerate(sorted(hs)):\n ret = max(ret, h + len(hs) - i)\n return ret\n\n\nprint((height(0)))\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**8)\nN = int(input())\nA = [int(input()) - 1 for i in range(N - 1)]\nwins = [[] for _ in range(N)]\nfor i, a in enumerate(A):\n wins[a].append(i + 1)\ndepth = [-1] * N\n\n\ndef dep(v):\n if len(wins[v]) == 0:\n return 0\n if depth[v] >= 0:\n return depth[v]\n ds = []\n for w in wins[v]:\n ds.append(dep(w))\n ds.sort(reverse=True)\n ret = 0\n for i, d in enumerate(ds):\n ret = max(ret, i + d + 1)\n depth[v] = ret\n return ret\n\n\nprint((dep(0)))\n", "code_same": false, "relative_loc_diff_percent": 25.0, "diff": ["-sys.setrecursionlimit(202020)", "+sys.setrecursionlimit(10**8)", "-won = [[] for i in range(N)]", "-for i in range(1, N):", "- a = int(input()) - 1", "- won[a].append(i)", "+A = [int(input()) - 1 for i in range(N - 1)]", "+wins = [[] for _ in range(N)]", "+for i, a in enumerate(A):", "+ wins[a].append(i + 1)", "+depth = [-1] * N", "-def height(v):", "- if not won[v]:", "+def dep(v):", "+ if len(wins[v]) == 0:", "- hs = [height(op) for op in won[v]]", "+ if depth[v] >= 0:", "+ return depth[v]", "+ ds = []", "+ for w in wins[v]:", "+ ds.append(dep(w))", "+ ds.sort(reverse=True)", "- for i, h in enumerate(sorted(hs)):", "- ret = max(ret, h + len(hs) - i)", "+ for i, d in enumerate(ds):", "+ ret = max(ret, i + d + 1)", "+ depth[v] = ret", "-print((height(0)))", "+print((dep(0)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3026691139, "measured_runtime_v1": 0.2050500124, "runtime_lift": 1.4760745946, "key": ["s508015569", "s203932637"]} {"user_id": "u775681539", "problem_id": "p02792", "language": "python", "submission_id_v0": "s313172456", "submission_id_v1": "s731114638", "cpu_time_v0": 533, "cpu_time_v1": 247, "memory_v0": 3444, "memory_v1": 40556, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 53.66, "input": "#python3\n\nfrom collections import defaultdict\n\nfrom collections import namedtuple\n\n\n\nP = namedtuple('P', ['front', 'end'])\n\n\n\ndef f(x):\n\n return P(str(x)[0], str(x)[-1]) \n\n\n\ndef main():\n\n\n\n n = int(input())\n\n freq = defaultdict(int)\n\n\n\n for i in range(1, n+1):\n\n p = f(i)\n\n freq[p]+=1\n\n\n\n\n\n ans = 0\n\n for i in range(1, n + 1):\n\n p = f(i)\n\n q = (p.end, p.front)\n\n ans += freq[q]\n\n\n\n print(ans)\n\n\n\nmain()", "target": "import sys\n\nread = sys.stdin.buffer.read\n\nreadline = sys.stdin.buffer.readline\n\nreadlines = sys.stdin.buffer.readlines\n\n\n\nfrom collections import defaultdict\n\n\n\ndef f(x):\n\n return (int(str(x)[0]), int(str(x)[-1])) \n\ndef main():\n\n N = int(readline())\n\n df = defaultdict(int)\n\n for i in range(1, N+1):\n\n df[f(i)] += 1\n\n ans = 0\n\n for i in range(1, 10):\n\n for j in range(1, 10):\n\n ans += df[(i, j)]*df[(j, i)]\n\n print(ans)\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 28, "code_v1_loc": 21, "code_v0_num_chars": 458, "code_v1_num_chars": 507, "code_v0_no_empty_lines": "# python3\nfrom collections import defaultdict\nfrom collections import namedtuple\n\nP = namedtuple(\"P\", [\"front\", \"end\"])\n\n\ndef f(x):\n return P(str(x)[0], str(x)[-1])\n\n\ndef main():\n n = int(input())\n freq = defaultdict(int)\n for i in range(1, n + 1):\n p = f(i)\n freq[p] += 1\n ans = 0\n for i in range(1, n + 1):\n p = f(i)\n q = (p.end, p.front)\n ans += freq[q]\n print(ans)\n\n\nmain()\n", "code_v1_no_empty_lines": "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom collections import defaultdict\n\n\ndef f(x):\n return (int(str(x)[0]), int(str(x)[-1]))\n\n\ndef main():\n N = int(readline())\n df = defaultdict(int)\n for i in range(1, N + 1):\n df[f(i)] += 1\n ans = 0\n for i in range(1, 10):\n for j in range(1, 10):\n ans += df[(i, j)] * df[(j, i)]\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 25.0, "diff": ["-# python3", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "-from collections import namedtuple", "-", "-P = namedtuple(\"P\", [\"front\", \"end\"])", "- return P(str(x)[0], str(x)[-1])", "+ return (int(str(x)[0]), int(str(x)[-1]))", "- n = int(input())", "- freq = defaultdict(int)", "- for i in range(1, n + 1):", "- p = f(i)", "- freq[p] += 1", "+ N = int(readline())", "+ df = defaultdict(int)", "+ for i in range(1, N + 1):", "+ df[f(i)] += 1", "- for i in range(1, n + 1):", "- p = f(i)", "- q = (p.end, p.front)", "- ans += freq[q]", "+ for i in range(1, 10):", "+ for j in range(1, 10):", "+ ans += df[(i, j)] * df[(j, i)]", "-main()", "+if __name__ == \"__main__\":", "+ main()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4672443939, "measured_runtime_v1": 0.3355342689, "runtime_lift": 1.3925385189, "key": ["s313172456", "s731114638"]} {"user_id": "u078042885", "problem_id": "p01138", "language": "python", "submission_id_v0": "s367659771", "submission_id_v1": "s546819347", "cpu_time_v0": 8280, "cpu_time_v1": 5620, "memory_v0": 11712, "memory_v1": 11664, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 32.13, "input": "def f(s):\n\n s=list(map(int,s.split(':')))\n\n return (s[0]*60+s[1])*60+s[2]\n\na=86401\n\nwhile 1:\n\n t=[0]*a\n\n n=int(input())\n\n if n==0:break\n\n for _ in range(n):\n\n b,c=input().split()\n\n t[f(b)]+=1;t[f(c)]-=1\n\n d=0\n\n for i in range(1,a):\n\n t[i]+=t[i-1]\n\n d=max(d,t[i])\n\n print(d)", "target": "def f(s):\n\n return (s[0]*60+s[1])*60+s[2]\n\na=86400\n\nwhile 1:\n\n t=[0]*a\n\n n=int(input())\n\n if n==0:break\n\n for _ in range(n):\n\n b,c = [list(map(int,x.split(':'))) for x in input().split()]\n\n t[f(b)]+=1;t[f(c)]-=1\n\n d=0\n\n for i in range(1,a):\n\n t[i]+=t[i-1]\n\n if d dp[j] + a:\n\n dp[j | key] = dp[j] + a\n\n\n\nif dp[-1] == INF:\n\n print((-1))\n\nelse:\n\n print((dp[-1]))", "code_v0_loc": 25, "code_v1_loc": 26, "code_v0_num_chars": 505, "code_v1_num_chars": 522, "code_v0_no_empty_lines": "import sys\n\nreadline = sys.stdin.readline\nN, M = list(map(int, readline().split()))\nINF = 10**10\ndp = [INF] * (2**N)\ndp[0] = 0\nfor i in range(M):\n a, b = list(map(int, readline().split()))\n c = list(map(int, readline().split()))\n key = 0\n for j in range(len(c)):\n key += 1 << (c[j] - 1)\n for j in range(len(dp)):\n if dp[j] == INF:\n continue\n if j | key == j:\n continue\n dp[j | key] = min(dp[j | key], dp[j] + a)\nif dp[-1] == INF:\n print((-1))\nelse:\n print((dp[-1]))\n", "code_v1_no_empty_lines": "import sys\n\nreadline = sys.stdin.readline\nN, M = list(map(int, readline().split()))\nINF = 10**10\ndp = [INF] * (2**N)\ndp[0] = 0\nfor i in range(M):\n a, b = list(map(int, readline().split()))\n c = list(map(int, readline().split()))\n key = 0\n for j in range(len(c)):\n key += 1 << (c[j] - 1)\n for j in range(len(dp)):\n if dp[j] == INF:\n continue\n if j | key == j:\n continue\n if dp[j | key] > dp[j] + a:\n dp[j | key] = dp[j] + a\nif dp[-1] == INF:\n print((-1))\nelse:\n print((dp[-1]))\n", "code_same": false, "relative_loc_diff_percent": 3.8461538462, "diff": ["- dp[j | key] = min(dp[j | key], dp[j] + a)", "+ if dp[j | key] > dp[j] + a:", "+ dp[j | key] = dp[j] + a"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2747366824, "measured_runtime_v1": 0.0058527424, "runtime_lift": 46.941529559, "key": ["s462370890", "s446448975"]} {"user_id": "u837673618", "problem_id": "p02721", "language": "python", "submission_id_v0": "s949081681", "submission_id_v1": "s434725940", "cpu_time_v0": 326, "cpu_time_v1": 177, "memory_v0": 12688, "memory_v1": 12576, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 45.71, "input": "N, K, C = list(map(int, input().split()))\n\nS = input()\n\n\n\nlatest = [None]*K\n\ni = len(S)+C\n\nfor j in range(K-1, -1, -1):\n\n i = S.rindex(\"o\", 0, i-C)\n\n latest[j] = i\n\n\n\nif i<=C or \"o\" not in S[:i-C]:\n\n i = -C-1\n\n for j in latest:\n\n i = S.index(\"o\", i+C+1)\n\n if i == j:\n\n print((i+1))\n", "target": "def solve():\n\n N, K, C = list(map(int, input().split()))\n\n workable = [i for i, s in enumerate(input()) if s==\"o\"]\n\n if len(workable) == K:\n\n return workable\n\n \n\n prev = workable[-1]\n\n latest = {prev}\n\n i = len(workable)-1\n\n while i > 0:\n\n i -= 1\n\n if prev - workable[i] > C:\n\n latest.add(workable[i])\n\n prev = workable[i]\n\n if len(latest) > K:\n\n return []\n\n must = []\n\n i = -1\n\n prev = -C-1\n\n while i < len(workable)-1:\n\n i += 1\n\n if workable[i] - prev > C:\n\n if workable[i] in latest:\n\n must.append(workable[i])\n\n prev = workable[i]\n\n return must\n\n\n\nfor i in solve():\n\n print((i+1))", "code_v0_loc": 15, "code_v1_loc": 29, "code_v0_num_chars": 289, "code_v1_num_chars": 646, "code_v0_no_empty_lines": "N, K, C = list(map(int, input().split()))\nS = input()\nlatest = [None] * K\ni = len(S) + C\nfor j in range(K - 1, -1, -1):\n i = S.rindex(\"o\", 0, i - C)\n latest[j] = i\nif i <= C or \"o\" not in S[: i - C]:\n i = -C - 1\n for j in latest:\n i = S.index(\"o\", i + C + 1)\n if i == j:\n print((i + 1))\n", "code_v1_no_empty_lines": "def solve():\n N, K, C = list(map(int, input().split()))\n workable = [i for i, s in enumerate(input()) if s == \"o\"]\n if len(workable) == K:\n return workable\n prev = workable[-1]\n latest = {prev}\n i = len(workable) - 1\n while i > 0:\n i -= 1\n if prev - workable[i] > C:\n latest.add(workable[i])\n prev = workable[i]\n if len(latest) > K:\n return []\n must = []\n i = -1\n prev = -C - 1\n while i < len(workable) - 1:\n i += 1\n if workable[i] - prev > C:\n if workable[i] in latest:\n must.append(workable[i])\n prev = workable[i]\n return must\n\n\nfor i in solve():\n print((i + 1))\n", "code_same": false, "relative_loc_diff_percent": 48.275862069, "diff": ["-N, K, C = list(map(int, input().split()))", "-S = input()", "-latest = [None] * K", "-i = len(S) + C", "-for j in range(K - 1, -1, -1):", "- i = S.rindex(\"o\", 0, i - C)", "- latest[j] = i", "-if i <= C or \"o\" not in S[: i - C]:", "- i = -C - 1", "- for j in latest:", "- i = S.index(\"o\", i + C + 1)", "- if i == j:", "- print((i + 1))", "+def solve():", "+ N, K, C = list(map(int, input().split()))", "+ workable = [i for i, s in enumerate(input()) if s == \"o\"]", "+ if len(workable) == K:", "+ return workable", "+ prev = workable[-1]", "+ latest = {prev}", "+ i = len(workable) - 1", "+ while i > 0:", "+ i -= 1", "+ if prev - workable[i] > C:", "+ latest.add(workable[i])", "+ prev = workable[i]", "+ if len(latest) > K:", "+ return []", "+ must = []", "+ i = -1", "+ prev = -C - 1", "+ while i < len(workable) - 1:", "+ i += 1", "+ if workable[i] - prev > C:", "+ if workable[i] in latest:", "+ must.append(workable[i])", "+ prev = workable[i]", "+ return must", "+", "+", "+for i in solve():", "+ print((i + 1))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3840038183, "measured_runtime_v1": 0.2943901448, "runtime_lift": 1.3044044613, "key": ["s949081681", "s434725940"]} {"user_id": "u754022296", "problem_id": "p03819", "language": "python", "submission_id_v0": "s951638556", "submission_id_v1": "s089571448", "cpu_time_v0": 1762, "cpu_time_v1": 852, "memory_v0": 127784, "memory_v1": 82324, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 51.65, "input": "import sys\n\ninput = sys.stdin.readline\n\n\n\ndef main():\n\n n, m = map(int, input().split())\n\n LR = [list(map(int, input().split())) for _ in range(n)]\n\n \n\n BIT = [0]*(m+2)\n\n def add(i, a):\n\n while i <= m+1:\n\n BIT[i] += a\n\n i += i&(-i)\n\n def bit_sum(i):\n\n res = 0\n\n while i > 0:\n\n res += BIT[i]\n\n i -= i&(-i)\n\n return res\n\n \n\n S = sorted([(r-l+1, l, r) for l, r in LR], reverse=True)\n\n cnt = n\n\n L = []\n\n for i in range(1, m+1):\n\n while S and S[-1][0] == i:\n\n c, l, r = S.pop()\n\n cnt -= 1\n\n add(l, 1)\n\n add(r+1, -1)\n\n res = cnt\n\n for j in range(0, m+1, i):\n\n res += bit_sum(j)\n\n L.append(res)\n\n print(*L, sep=\"\\n\")\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "import sys\n\ninput = sys.stdin.readline\n\n\n\ndef main():\n\n n, m = list(map(int, input().split()))\n\n S = [[] for _ in range(m+1)]\n\n for _ in range(n):\n\n l, r = list(map(int, input().split()))\n\n S[r-l+1].append((l, r))\n\n \n\n BIT = [0]*(m+2)\n\n def add(i, a):\n\n while i <= m+1:\n\n BIT[i] += a\n\n i += i&(-i)\n\n def bit_sum(i):\n\n res = 0\n\n while i > 0:\n\n res += BIT[i]\n\n i -= i&(-i)\n\n return res\n\n cnt = n\n\n for i in range(1, m+1):\n\n for l, r in S[i]:\n\n cnt -= 1\n\n add(l, 1)\n\n add(r+1, -1)\n\n res = cnt\n\n for j in range(0, m+1, i):\n\n res += bit_sum(j)\n\n print(res)\n\n\n\nif __name__ == \"__main__\":\n\n main()", "code_v0_loc": 36, "code_v1_loc": 34, "code_v0_num_chars": 731, "code_v1_num_chars": 658, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n n, m = map(int, input().split())\n LR = [list(map(int, input().split())) for _ in range(n)]\n BIT = [0] * (m + 2)\n\n def add(i, a):\n while i <= m + 1:\n BIT[i] += a\n i += i & (-i)\n\n def bit_sum(i):\n res = 0\n while i > 0:\n res += BIT[i]\n i -= i & (-i)\n return res\n\n S = sorted([(r - l + 1, l, r) for l, r in LR], reverse=True)\n cnt = n\n L = []\n for i in range(1, m + 1):\n while S and S[-1][0] == i:\n c, l, r = S.pop()\n cnt -= 1\n add(l, 1)\n add(r + 1, -1)\n res = cnt\n for j in range(0, m + 1, i):\n res += bit_sum(j)\n L.append(res)\n print(*L, sep=\"\\n\")\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n n, m = list(map(int, input().split()))\n S = [[] for _ in range(m + 1)]\n for _ in range(n):\n l, r = list(map(int, input().split()))\n S[r - l + 1].append((l, r))\n BIT = [0] * (m + 2)\n\n def add(i, a):\n while i <= m + 1:\n BIT[i] += a\n i += i & (-i)\n\n def bit_sum(i):\n res = 0\n while i > 0:\n res += BIT[i]\n i -= i & (-i)\n return res\n\n cnt = n\n for i in range(1, m + 1):\n for l, r in S[i]:\n cnt -= 1\n add(l, 1)\n add(r + 1, -1)\n res = cnt\n for j in range(0, m + 1, i):\n res += bit_sum(j)\n print(res)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 5.5555555556, "diff": ["- n, m = map(int, input().split())", "- LR = [list(map(int, input().split())) for _ in range(n)]", "+ n, m = list(map(int, input().split()))", "+ S = [[] for _ in range(m + 1)]", "+ for _ in range(n):", "+ l, r = list(map(int, input().split()))", "+ S[r - l + 1].append((l, r))", "- S = sorted([(r - l + 1, l, r) for l, r in LR], reverse=True)", "- L = []", "- while S and S[-1][0] == i:", "- c, l, r = S.pop()", "+ for l, r in S[i]:", "- L.append(res)", "- print(*L, sep=\"\\n\")", "+ print(res)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3067650649, "measured_runtime_v1": 0.0989195189, "runtime_lift": 3.1011580763, "key": ["s951638556", "s089571448"]} {"user_id": "u046187684", "problem_id": "p03480", "language": "python", "submission_id_v0": "s964601714", "submission_id_v1": "s413566853", "cpu_time_v0": 40, "cpu_time_v1": 33, "memory_v0": 6244, "memory_v1": 6388, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 17.5, "input": "#!/usr/bin/env python3\n\n# coding=utf-8\n\n\n\nimport sys\n\n\n\ns = sys.stdin.readline().strip()\n\nl = [_s is \"1\" for _s in list(s)]\n\nl_r = l[::-1]\n\nindex = 0\n\nfor i, (c, n, c_r, n_r) in enumerate(\n\n zip(l[:len(s) // 2], l[1:len(s) // 2 + 1], l_r[:len(s) // 2], l_r[1:len(s) // 2 + 1])):\n\n if c ^ n or c_r ^ n_r:\n\n index = i + 1\n\nprint((len(s) - index))", "target": "def solve(string):\n\n l = [s == \"1\" for s in string]\n\n l_r = l[::-1]\n\n index = 0\n\n h = len(string) // 2\n\n for i, (c, n, c_r, n_r) in enumerate(zip(l[:h], l[1:h + 1], l_r[:h], l_r[1:h + 1])):\n\n if c ^ n or c_r ^ n_r:\n\n index = i + 1\n\n return str(len(string) - index)\n\n\n\n\n\nif __name__ == '__main__':\n\n print((solve(input())))\n", "code_v0_loc": 14, "code_v1_loc": 13, "code_v0_num_chars": 359, "code_v1_num_chars": 360, "code_v0_no_empty_lines": "#!/usr/bin/env python3\n# coding=utf-8\nimport sys\n\ns = sys.stdin.readline().strip()\nl = [_s is \"1\" for _s in list(s)]\nl_r = l[::-1]\nindex = 0\nfor i, (c, n, c_r, n_r) in enumerate(\n zip(\n l[: len(s) // 2],\n l[1 : len(s) // 2 + 1],\n l_r[: len(s) // 2],\n l_r[1 : len(s) // 2 + 1],\n )\n):\n if c ^ n or c_r ^ n_r:\n index = i + 1\nprint((len(s) - index))\n", "code_v1_no_empty_lines": "def solve(string):\n l = [s == \"1\" for s in string]\n l_r = l[::-1]\n index = 0\n h = len(string) // 2\n for i, (c, n, c_r, n_r) in enumerate(\n zip(l[:h], l[1 : h + 1], l_r[:h], l_r[1 : h + 1])\n ):\n if c ^ n or c_r ^ n_r:\n index = i + 1\n return str(len(string) - index)\n\n\nif __name__ == \"__main__\":\n print((solve(input())))\n", "code_same": false, "relative_loc_diff_percent": 7.1428571429, "diff": ["-#!/usr/bin/env python3", "-# coding=utf-8", "-import sys", "+def solve(string):", "+ l = [s == \"1\" for s in string]", "+ l_r = l[::-1]", "+ index = 0", "+ h = len(string) // 2", "+ for i, (c, n, c_r, n_r) in enumerate(", "+ zip(l[:h], l[1 : h + 1], l_r[:h], l_r[1 : h + 1])", "+ ):", "+ if c ^ n or c_r ^ n_r:", "+ index = i + 1", "+ return str(len(string) - index)", "-s = sys.stdin.readline().strip()", "-l = [_s is \"1\" for _s in list(s)]", "-l_r = l[::-1]", "-index = 0", "-for i, (c, n, c_r, n_r) in enumerate(", "- zip(", "- l[: len(s) // 2],", "- l[1 : len(s) // 2 + 1],", "- l_r[: len(s) // 2],", "- l_r[1 : len(s) // 2 + 1],", "- )", "-):", "- if c ^ n or c_r ^ n_r:", "- index = i + 1", "-print((len(s) - index))", "+", "+if __name__ == \"__main__\":", "+ print((solve(input())))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3417459049, "measured_runtime_v1": 0.2085829885, "runtime_lift": 1.6384169551, "key": ["s964601714", "s413566853"]} {"user_id": "u318414416", "problem_id": "p03162", "language": "python", "submission_id_v0": "s337419843", "submission_id_v1": "s763303888", "cpu_time_v0": 672, "cpu_time_v1": 308, "memory_v0": 47336, "memory_v1": 30580, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 54.17, "input": "# coding: utf-8\n\n\n\nimport sys\n\ninput = sys.stdin.readline\n\n\n\ndef f(n, abc):\n\n dp = [[0] * 3 for _ in range(n + 1)]\n\n for i in range(1, n + 1):\n\n for j in range(3):\n\n dp[i][j] = max(dp[i - 1][k] + abc[i - 1][j] \\\n\n for k in range(3) if k != j)\n\n return(max(dp[n]))\n\n\n\nn = int(input()) # 1 <= n <= 10^5\n\nabc = [list(map(int, input().rstrip().split())) for _ in range(n)]\n\n\n\nprint((f(n, abc)))\n", "target": "# coding: utf-8\n\nimport sys\n\ninput = sys.stdin.readline\n\n\n\ndef f(n, abc):\n\n dp = [0] * 3\n\n for i in range(1, n + 1):\n\n a, b, c = abc[i - 1]\n\n dp = [ max(dp[1] + a, dp[2] + a), \\\n\n max(dp[0] + b, dp[2] + b), \\\n\n max(dp[0] + c, dp[1] + c) ]\n\n return(max(dp))\n\n\n\nn = int(input()) # 1 <= n <= 10^5\n\nabc = [list(map(int, input().rstrip().split())) for _ in range(n)]\n\n\n\nprint((f(n, abc)))\n", "code_v0_loc": 17, "code_v1_loc": 17, "code_v0_num_chars": 434, "code_v1_num_chars": 436, "code_v0_no_empty_lines": "# coding: utf-8\nimport sys\n\ninput = sys.stdin.readline\n\n\ndef f(n, abc):\n dp = [[0] * 3 for _ in range(n + 1)]\n for i in range(1, n + 1):\n for j in range(3):\n dp[i][j] = max(dp[i - 1][k] + abc[i - 1][j] for k in range(3) if k != j)\n return max(dp[n])\n\n\nn = int(input()) # 1 <= n <= 10^5\nabc = [list(map(int, input().rstrip().split())) for _ in range(n)]\nprint((f(n, abc)))\n", "code_v1_no_empty_lines": "# coding: utf-8\nimport sys\n\ninput = sys.stdin.readline\n\n\ndef f(n, abc):\n dp = [0] * 3\n for i in range(1, n + 1):\n a, b, c = abc[i - 1]\n dp = [\n max(dp[1] + a, dp[2] + a),\n max(dp[0] + b, dp[2] + b),\n max(dp[0] + c, dp[1] + c),\n ]\n return max(dp)\n\n\nn = int(input()) # 1 <= n <= 10^5\nabc = [list(map(int, input().rstrip().split())) for _ in range(n)]\nprint((f(n, abc)))\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- dp = [[0] * 3 for _ in range(n + 1)]", "+ dp = [0] * 3", "- for j in range(3):", "- dp[i][j] = max(dp[i - 1][k] + abc[i - 1][j] for k in range(3) if k != j)", "- return max(dp[n])", "+ a, b, c = abc[i - 1]", "+ dp = [", "+ max(dp[1] + a, dp[2] + a),", "+ max(dp[0] + b, dp[2] + b),", "+ max(dp[0] + c, dp[1] + c),", "+ ]", "+ return max(dp)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2527067475, "measured_runtime_v1": 0.1473037755, "runtime_lift": 1.7155483393, "key": ["s337419843", "s763303888"]} {"user_id": "u816872429", "problem_id": "p03078", "language": "python", "submission_id_v0": "s052587697", "submission_id_v1": "s157699880", "cpu_time_v0": 41, "cpu_time_v1": 28, "memory_v0": 4096, "memory_v1": 4460, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 31.71, "input": "import heapq\n\n\n\nx, y, z, k = list(map(int, input().split()))\n\na = list(map(int, input().split()))\n\nb = list(map(int, input().split()))\n\nc = list(map(int, input().split()))\n\n\n\ndef diff(l):\n\n m = max(l)\n\n return sorted(m - v for v in l)[1:]\n\n\n\ns = sum(map(max, [a, b, c]))\n\nsa, sb, sc = list(map(diff, [a, b, c]))\n\nda, db, dc = [0], [0], [0]\n\nq = [0]\n\nwhile k > 0:\n\n while True:\n\n if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):\n\n for v in [sa[0] + bb + cc for bb in db for cc in dc]:\n\n heapq.heappush(q, v)\n\n da.append(sa[0])\n\n sa = sa[1:]\n\n elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):\n\n for v in [sb[0] + aa + cc for aa in da for cc in dc]:\n\n heapq.heappush(q, v)\n\n db.append(sb[0])\n\n sb = sb[1:]\n\n elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):\n\n for v in [sc[0] + aa + bb for aa in da for bb in db]:\n\n heapq.heappush(q, v)\n\n dc.append(sc[0])\n\n sc = sc[1:]\n\n else:\n\n break\n\n v = heapq.heappop(q)\n\n print(s - v)\n\n k -= 1\n", "target": "import heapq\n\n\n\nx, y, z, k = list(map(int, input().split()))\n\na = sorted(map(int, input().split()))\n\nb = sorted(map(int, input().split()))\n\nc = sorted(map(int, input().split()))\n\n\n\nq = []\n\nmemo = set()\n\ndef qpush(q, ai, bi, ci):\n\n t = (-(a[ai] + b[bi] + c[ci]), ai, bi, ci)\n\n if not t in memo:\n\n memo.add(t)\n\n heapq.heappush(q, t)\n\n\n\nqpush(q, len(a) - 1, len(b) - 1, len(c) - 1)\n\nfor _ in range(k):\n\n s, ai, bi, ci = heapq.heappop(q)\n\n if ai > 0:\n\n qpush(q, ai - 1, bi, ci)\n\n if bi > 0:\n\n qpush(q, ai, bi - 1, ci)\n\n if ci > 0:\n\n qpush(q, ai, bi, ci - 1)\n\n print(-s)\n", "code_v0_loc": 37, "code_v1_loc": 25, "code_v0_num_chars": 1122, "code_v1_num_chars": 631, "code_v0_no_empty_lines": "import heapq\n\nx, y, z, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\n\ndef diff(l):\n m = max(l)\n return sorted(m - v for v in l)[1:]\n\n\ns = sum(map(max, [a, b, c]))\nsa, sb, sc = list(map(diff, [a, b, c]))\nda, db, dc = [0], [0], [0]\nq = [0]\nwhile k > 0:\n while True:\n if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):\n for v in [sa[0] + bb + cc for bb in db for cc in dc]:\n heapq.heappush(q, v)\n da.append(sa[0])\n sa = sa[1:]\n elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):\n for v in [sb[0] + aa + cc for aa in da for cc in dc]:\n heapq.heappush(q, v)\n db.append(sb[0])\n sb = sb[1:]\n elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):\n for v in [sc[0] + aa + bb for aa in da for bb in db]:\n heapq.heappush(q, v)\n dc.append(sc[0])\n sc = sc[1:]\n else:\n break\n v = heapq.heappop(q)\n print(s - v)\n k -= 1\n", "code_v1_no_empty_lines": "import heapq\n\nx, y, z, k = list(map(int, input().split()))\na = sorted(map(int, input().split()))\nb = sorted(map(int, input().split()))\nc = sorted(map(int, input().split()))\nq = []\nmemo = set()\n\n\ndef qpush(q, ai, bi, ci):\n t = (-(a[ai] + b[bi] + c[ci]), ai, bi, ci)\n if not t in memo:\n memo.add(t)\n heapq.heappush(q, t)\n\n\nqpush(q, len(a) - 1, len(b) - 1, len(c) - 1)\nfor _ in range(k):\n s, ai, bi, ci = heapq.heappop(q)\n if ai > 0:\n qpush(q, ai - 1, bi, ci)\n if bi > 0:\n qpush(q, ai, bi - 1, ci)\n if ci > 0:\n qpush(q, ai, bi, ci - 1)\n print(-s)\n", "code_same": false, "relative_loc_diff_percent": 32.4324324324, "diff": ["-a = list(map(int, input().split()))", "-b = list(map(int, input().split()))", "-c = list(map(int, input().split()))", "+a = sorted(map(int, input().split()))", "+b = sorted(map(int, input().split()))", "+c = sorted(map(int, input().split()))", "+q = []", "+memo = set()", "-def diff(l):", "- m = max(l)", "- return sorted(m - v for v in l)[1:]", "+def qpush(q, ai, bi, ci):", "+ t = (-(a[ai] + b[bi] + c[ci]), ai, bi, ci)", "+ if not t in memo:", "+ memo.add(t)", "+ heapq.heappush(q, t)", "-s = sum(map(max, [a, b, c]))", "-sa, sb, sc = list(map(diff, [a, b, c]))", "-da, db, dc = [0], [0], [0]", "-q = [0]", "-while k > 0:", "- while True:", "- if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):", "- for v in [sa[0] + bb + cc for bb in db for cc in dc]:", "- heapq.heappush(q, v)", "- da.append(sa[0])", "- sa = sa[1:]", "- elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):", "- for v in [sb[0] + aa + cc for aa in da for cc in dc]:", "- heapq.heappush(q, v)", "- db.append(sb[0])", "- sb = sb[1:]", "- elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):", "- for v in [sc[0] + aa + bb for aa in da for bb in db]:", "- heapq.heappush(q, v)", "- dc.append(sc[0])", "- sc = sc[1:]", "- else:", "- break", "- v = heapq.heappop(q)", "- print(s - v)", "- k -= 1", "+qpush(q, len(a) - 1, len(b) - 1, len(c) - 1)", "+for _ in range(k):", "+ s, ai, bi, ci = heapq.heappop(q)", "+ if ai > 0:", "+ qpush(q, ai - 1, bi, ci)", "+ if bi > 0:", "+ qpush(q, ai, bi - 1, ci)", "+ if ci > 0:", "+ qpush(q, ai, bi, ci - 1)", "+ print(-s)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2304672, "measured_runtime_v1": 0.0062596636, "runtime_lift": 36.8178252168, "key": ["s052587697", "s157699880"]} {"user_id": "u924691798", "problem_id": "p02837", "language": "python", "submission_id_v0": "s473277676", "submission_id_v1": "s669766257", "cpu_time_v0": 175, "cpu_time_v1": 139, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 20.57, "input": "N = int(input())\n\nA = [0]*N\n\nX = []\n\nY = []\n\nfor i in range(N):\n\n A[i] = int(input())\n\n X.append([])\n\n Y.append([])\n\n for j in range(A[i]):\n\n x, y = list(map(int, input().split()))\n\n X[i].append(x-1)\n\n Y[i].append(y)\n\nans = 0\n\nfor bit in range(1<=1:\n\n t[x][y] |= not dfs(x-1, y)\n\n \n\n if y>=1:\n\n t[x][y] |= not dfs(x, y-1)\n\n \n\n if min(x, y)>=1:\n\n t[x][y] |= not dfs(x-1, y-1)\n\n \n\n return t[x][y]\n\n \n\nt = [[False]*7 for _ in range(7)]\n\n\n\nfor i in range(7):\n\n for j in range(7):\n\n dfs(i, j)\n\n\n\n\"\"\"\n\nfor ti in t:\n\n print(*ti)\n\n\"\"\"\n\n\n\nN = int(input())\n\nflag = True\n\n\n\nfor _ in range(N):\n\n a = int(input())\n\n \n\n if a%2==1:\n\n flag = False\n\n \n\nif flag:\n\n print('second')\n\nelse:\n\n print('first')", "target": "import sys\n\ninput = sys.stdin.readline\n\n\n\n\"\"\"\n\ndef dfs(x, y):\n\n if x==0 and y==0:\n\n return False\n\n \n\n res = False\n\n \n\n if x>0:\n\n res |= not dfs(x-1, y)\n\n \n\n if y>0:\n\n res |= not dfs(x, y-1)\n\n \n\n if min(x, y)>0:\n\n res |= not dfs(x-1, y-1)\n\n \n\n return res\n\n \n\nt = [[False]*5 for _ in range(5)]\n\n\n\nfor i in range(5):\n\n for j in range(5):\n\n t[i][j] = dfs(i, j)\n\n\n\nfor ti in t:\n\n print(*ti)\n\n\"\"\"\n\n\n\nN = int(input())\n\na = [int(input()) for _ in range(N)]\n\n\n\nfor ai in a:\n\n if ai%2==1:\n\n print('first')\n\n exit()\n\n\n\nprint('second')", "code_v0_loc": 44, "code_v1_loc": 40, "code_v0_num_chars": 701, "code_v1_num_chars": 621, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nfrom collections import *\n\n\ndef dfs(x, y):\n if x == 0 and y == 0:\n t[x][y] = False\n return False\n if x >= 1:\n t[x][y] |= not dfs(x - 1, y)\n if y >= 1:\n t[x][y] |= not dfs(x, y - 1)\n if min(x, y) >= 1:\n t[x][y] |= not dfs(x - 1, y - 1)\n return t[x][y]\n\n\nt = [[False] * 7 for _ in range(7)]\nfor i in range(7):\n for j in range(7):\n dfs(i, j)\n\"\"\"\nfor ti in t:\n print(*ti)\n\"\"\"\nN = int(input())\nflag = True\nfor _ in range(N):\n a = int(input())\n if a % 2 == 1:\n flag = False\nif flag:\n print(\"second\")\nelse:\n print(\"first\")\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\n\"\"\"\ndef dfs(x, y):\n if x==0 and y==0:\n return False\n res = False\n if x>0:\n res |= not dfs(x-1, y)\n if y>0:\n res |= not dfs(x, y-1)\n if min(x, y)>0:\n res |= not dfs(x-1, y-1)\n return res\nt = [[False]*5 for _ in range(5)]\nfor i in range(5):\n for j in range(5):\n t[i][j] = dfs(i, j)\nfor ti in t:\n print(*ti)\n\"\"\"\nN = int(input())\na = [int(input()) for _ in range(N)]\nfor ai in a:\n if ai % 2 == 1:\n print(\"first\")\n exit()\nprint(\"second\")\n", "code_same": false, "relative_loc_diff_percent": 9.0909090909, "diff": ["-from collections import *", "-", "-", "+\"\"\"", "- if x == 0 and y == 0:", "- t[x][y] = False", "+ if x==0 and y==0:", "- if x >= 1:", "- t[x][y] |= not dfs(x - 1, y)", "- if y >= 1:", "- t[x][y] |= not dfs(x, y - 1)", "- if min(x, y) >= 1:", "- t[x][y] |= not dfs(x - 1, y - 1)", "- return t[x][y]", "-", "-", "-t = [[False] * 7 for _ in range(7)]", "-for i in range(7):", "- for j in range(7):", "- dfs(i, j)", "-\"\"\"", "+ res = False", "+ if x>0:", "+ res |= not dfs(x-1, y)", "+ if y>0:", "+ res |= not dfs(x, y-1)", "+ if min(x, y)>0:", "+ res |= not dfs(x-1, y-1)", "+ return res", "+t = [[False]*5 for _ in range(5)]", "+for i in range(5):", "+ for j in range(5):", "+ t[i][j] = dfs(i, j)", "-flag = True", "-for _ in range(N):", "- a = int(input())", "- if a % 2 == 1:", "- flag = False", "-if flag:", "- print(\"second\")", "-else:", "- print(\"first\")", "+a = [int(input()) for _ in range(N)]", "+for ai in a:", "+ if ai % 2 == 1:", "+ print(\"first\")", "+ exit()", "+print(\"second\")"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4127988609, "measured_runtime_v1": 0.1956315268, "runtime_lift": 2.1100835213, "key": ["s531607176", "s450058032"]} {"user_id": "u381572531", "problem_id": "p02891", "language": "python", "submission_id_v0": "s581989830", "submission_id_v1": "s729822755", "cpu_time_v0": 20, "cpu_time_v1": 17, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 15.0, "input": "import sys\n\ninput = sys.stdin.readline\n\n \n\ns = input().rstrip()\n\nk = int(input())\n\n \n\ndef check_count(s):\n\n cnt_list = [1]\n\n cnt = 1\n\n for i in range(1, len(s)):\n\n if s[i-1] == s[i]:\n\n cnt_list[-1] += 1\n\n else:\n\n cnt_list.append(1)\n\n return cnt_list\n\n\n\ndef calc_ans(cnt_list, k):\n\n _ans = 0\n\n for c in cnt_list:\n\n _ans += c//2\n\n return(_ans * k)\n\n\n\nif len(s)==1:\n\n ans = k//2\n\nelse:\n\n cnt_list = check_count(s)\n\n if len(cnt_list)==1:\n\n ans = (len(s)*k)//2\n\n else:\n\n ans = calc_ans(cnt_list, k)\n\n if s[0]==s[-1]:\n\n if cnt_list[0]%2==1 and cnt_list[-1]%2==1:\n\n ans += k - 1\n\n\n\nprint(ans)", "target": "import sys\n\ninput = sys.stdin.readline\n\n \n\ns = input().rstrip()\n\nk = int(input())\n\n\n\ndef check_count(s):\n\n cnt_list = []\n\n cnt = 1\n\n for i in range(1, len(s)):\n\n if s[i-1] == s[i]:\n\n cnt += 1\n\n else:\n\n cnt_list.append(cnt)\n\n cnt = 1\n\n if cnt>1:\n\n cnt_list.append(cnt)\n\n return cnt_list\n\n\n\ndef calc_ans(cnt_list, k):\n\n _ans = 0\n\n for c in cnt_list:\n\n _ans += c//2\n\n return(_ans * k)\n\n\n\nif len(s)==1:\n\n ans = k//2\n\nelse:\n\n cnt_list = check_count(s)\n\n if len(cnt_list)==1:\n\n ans = (len(s)*k)//2\n\n else:\n\n ans = calc_ans(cnt_list, k)\n\n if s[0]==s[-1]:\n\n if cnt_list[0]%2==1 and cnt_list[-1]%2==1:\n\n ans += k - 1\n\n\n\nprint(ans)", "code_v0_loc": 35, "code_v1_loc": 38, "code_v0_num_chars": 711, "code_v1_num_chars": 765, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\ns = input().rstrip()\nk = int(input())\n\n\ndef check_count(s):\n cnt_list = [1]\n cnt = 1\n for i in range(1, len(s)):\n if s[i - 1] == s[i]:\n cnt_list[-1] += 1\n else:\n cnt_list.append(1)\n return cnt_list\n\n\ndef calc_ans(cnt_list, k):\n _ans = 0\n for c in cnt_list:\n _ans += c // 2\n return _ans * k\n\n\nif len(s) == 1:\n ans = k // 2\nelse:\n cnt_list = check_count(s)\n if len(cnt_list) == 1:\n ans = (len(s) * k) // 2\n else:\n ans = calc_ans(cnt_list, k)\n if s[0] == s[-1]:\n if cnt_list[0] % 2 == 1 and cnt_list[-1] % 2 == 1:\n ans += k - 1\nprint(ans)\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\ns = input().rstrip()\nk = int(input())\n\n\ndef check_count(s):\n cnt_list = []\n cnt = 1\n for i in range(1, len(s)):\n if s[i - 1] == s[i]:\n cnt += 1\n else:\n cnt_list.append(cnt)\n cnt = 1\n if cnt > 1:\n cnt_list.append(cnt)\n return cnt_list\n\n\ndef calc_ans(cnt_list, k):\n _ans = 0\n for c in cnt_list:\n _ans += c // 2\n return _ans * k\n\n\nif len(s) == 1:\n ans = k // 2\nelse:\n cnt_list = check_count(s)\n if len(cnt_list) == 1:\n ans = (len(s) * k) // 2\n else:\n ans = calc_ans(cnt_list, k)\n if s[0] == s[-1]:\n if cnt_list[0] % 2 == 1 and cnt_list[-1] % 2 == 1:\n ans += k - 1\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 7.8947368421, "diff": ["- cnt_list = [1]", "+ cnt_list = []", "- cnt_list[-1] += 1", "+ cnt += 1", "- cnt_list.append(1)", "+ cnt_list.append(cnt)", "+ cnt = 1", "+ if cnt > 1:", "+ cnt_list.append(cnt)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3312115214, "measured_runtime_v1": 0.249056649, "runtime_lift": 1.3298642006, "key": ["s581989830", "s729822755"]} {"user_id": "u827885761", "problem_id": "p03013", "language": "python", "submission_id_v0": "s193052587", "submission_id_v1": "s829443238", "cpu_time_v0": 509, "cpu_time_v1": 195, "memory_v0": 46168, "memory_v1": 7668, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 61.69, "input": "import sys\n\nsys.setrecursionlimit(10**7)\n\ndef lmi(): return list(map(int, input().split()))\n\n\n\nn, m = lmi()\n\n\n\nl = [0] * (n+1)\n\nl[0] = 1\n\n\n\na = 0\n\nif m != 0:\n\n a = int(input())\n\nk = 1\n\nfor i in range(n+1):\n\n\n\n if i != a:\n\n if i == 1:\n\n l[i] = 1\n\n elif i >= 2:\n\n l[i] = l[i-1] + l[i-2]\n\n l[i] %= 1000000007\n\n else:\n\n k += 1\n\n if k <= m:\n\n a = int(input())\n\n\n\n\n\n\n\n#print(l)\n\nprint((l[n] % 1000000007))\n", "target": "import sys\n\nsys.setrecursionlimit(10**7)\n\ndef lmi(): return list(map(int, input().split()))\n\n\n\nn, m = lmi()\n\na = [1] * (n+1)\n\nfor i in range(m):\n\n a[int(input())] = 0\n\nk = [0] * (n+1)\n\nk[0] = 1\n\nfor i in range(1,n+1):\n\n if i == 1 and a[1]:\n\n k[1] = 1\n\n elif i >= 2 and a[i]:\n\n k[i] = k[i-1] + k[i-2]\n\n k[i] %= 10 ** 9 + 7\n\n\n\nprint((k[n]))\n", "code_v0_loc": 30, "code_v1_loc": 18, "code_v0_num_chars": 479, "code_v1_num_chars": 367, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**7)\n\n\ndef lmi():\n return list(map(int, input().split()))\n\n\nn, m = lmi()\nl = [0] * (n + 1)\nl[0] = 1\na = 0\nif m != 0:\n a = int(input())\nk = 1\nfor i in range(n + 1):\n if i != a:\n if i == 1:\n l[i] = 1\n elif i >= 2:\n l[i] = l[i - 1] + l[i - 2]\n l[i] %= 1000000007\n else:\n k += 1\n if k <= m:\n a = int(input())\n# print(l)\nprint((l[n] % 1000000007))\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(10**7)\n\n\ndef lmi():\n return list(map(int, input().split()))\n\n\nn, m = lmi()\na = [1] * (n + 1)\nfor i in range(m):\n a[int(input())] = 0\nk = [0] * (n + 1)\nk[0] = 1\nfor i in range(1, n + 1):\n if i == 1 and a[1]:\n k[1] = 1\n elif i >= 2 and a[i]:\n k[i] = k[i - 1] + k[i - 2]\n k[i] %= 10**9 + 7\nprint((k[n]))\n", "code_same": false, "relative_loc_diff_percent": 40.0, "diff": ["-l = [0] * (n + 1)", "-l[0] = 1", "-a = 0", "-if m != 0:", "- a = int(input())", "-k = 1", "-for i in range(n + 1):", "- if i != a:", "- if i == 1:", "- l[i] = 1", "- elif i >= 2:", "- l[i] = l[i - 1] + l[i - 2]", "- l[i] %= 1000000007", "- else:", "- k += 1", "- if k <= m:", "- a = int(input())", "-# print(l)", "-print((l[n] % 1000000007))", "+a = [1] * (n + 1)", "+for i in range(m):", "+ a[int(input())] = 0", "+k = [0] * (n + 1)", "+k[0] = 1", "+for i in range(1, n + 1):", "+ if i == 1 and a[1]:", "+ k[1] = 1", "+ elif i >= 2 and a[i]:", "+ k[i] = k[i - 1] + k[i - 2]", "+ k[i] %= 10**9 + 7", "+print((k[n]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3120539634, "measured_runtime_v1": 0.1110639279, "runtime_lift": 2.8096787978, "key": ["s193052587", "s829443238"]} {"user_id": "u228223940", "problem_id": "p03634", "language": "python", "submission_id_v0": "s279386500", "submission_id_v1": "s990337521", "cpu_time_v0": 1565, "cpu_time_v1": 1313, "memory_v0": 113180, "memory_v1": 156176, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 16.1, "input": "import queue\n\nn = int(input())\n\n\n\nabc = [[] for i in range(n+1)]\n\n\n\nfor i in range(n-1):\n\n a,b,c = list(map(int,input().split()))\n\n abc[a].append([b,c])\n\n abc[b].append([a,c])\n\n\n\nQ,k = list(map(int,input().split()))\n\nxy = [[int(i) for i in input().split()] for j in range(Q)]\n\n\n\nq = queue.Queue()\n\n\n\nq.put(k)\n\n\n\npath = [-1]*(n+1)\n\npath[k] = 0\n\n\n\nwhile not q.empty():\n\n tmp = q.get()\n\n for i in range(len(abc[tmp])):\n\n #print(abc[tmp])\n\n #exit()\n\n num = abc[tmp][i][0]\n\n if path[num] != -1:\n\n continue\n\n else:\n\n path[num] = path[tmp] + abc[tmp][i][1]\n\n q.put(num)\n\n \n\nfor i in range(Q):\n\n print((path[xy[i][0]]+path[xy[i][1]]))", "target": "import queue\n\nimport sys\n\nsys.setrecursionlimit(10**7)\n\nn = int(input())\n\n\n\nabc = [[] for i in range(n+1)]\n\n\n\nfor i in range(n-1):\n\n a,b,c = list(map(int,input().split()))\n\n abc[a].append([b,c])\n\n abc[b].append([a,c])\n\n\n\nQ,k = list(map(int,input().split()))\n\nxy = [[int(i) for i in input().split()] for j in range(Q)]\n\n\n\nq = queue.Queue()\n\n\n\nq.put(k)\n\n\n\npath = [-1]*(n+1)\n\npath[k] = 0\n\n\n\ndef dfs(p):\n\n for i in range(len(abc[p])):\n\n num = abc[p][i][0]\n\n if path[num] != -1:\n\n continue\n\n else:\n\n path[num] = path[p] + abc[p][i][1]\n\n dfs(num)\n\n\n\ndfs(k)\n\n\n\nfor i in range(Q):\n\n print((path[xy[i][0]]+path[xy[i][1]]))", "code_v0_loc": 34, "code_v1_loc": 35, "code_v0_num_chars": 709, "code_v1_num_chars": 668, "code_v0_no_empty_lines": "import queue\n\nn = int(input())\nabc = [[] for i in range(n + 1)]\nfor i in range(n - 1):\n a, b, c = list(map(int, input().split()))\n abc[a].append([b, c])\n abc[b].append([a, c])\nQ, k = list(map(int, input().split()))\nxy = [[int(i) for i in input().split()] for j in range(Q)]\nq = queue.Queue()\nq.put(k)\npath = [-1] * (n + 1)\npath[k] = 0\nwhile not q.empty():\n tmp = q.get()\n for i in range(len(abc[tmp])):\n # print(abc[tmp])\n # exit()\n num = abc[tmp][i][0]\n if path[num] != -1:\n continue\n else:\n path[num] = path[tmp] + abc[tmp][i][1]\n q.put(num)\nfor i in range(Q):\n print((path[xy[i][0]] + path[xy[i][1]]))\n", "code_v1_no_empty_lines": "import queue\nimport sys\n\nsys.setrecursionlimit(10**7)\nn = int(input())\nabc = [[] for i in range(n + 1)]\nfor i in range(n - 1):\n a, b, c = list(map(int, input().split()))\n abc[a].append([b, c])\n abc[b].append([a, c])\nQ, k = list(map(int, input().split()))\nxy = [[int(i) for i in input().split()] for j in range(Q)]\nq = queue.Queue()\nq.put(k)\npath = [-1] * (n + 1)\npath[k] = 0\n\n\ndef dfs(p):\n for i in range(len(abc[p])):\n num = abc[p][i][0]\n if path[num] != -1:\n continue\n else:\n path[num] = path[p] + abc[p][i][1]\n dfs(num)\n\n\ndfs(k)\nfor i in range(Q):\n print((path[xy[i][0]] + path[xy[i][1]]))\n", "code_same": false, "relative_loc_diff_percent": 2.8571428571, "diff": ["+import sys", "+sys.setrecursionlimit(10**7)", "-while not q.empty():", "- tmp = q.get()", "- for i in range(len(abc[tmp])):", "- # print(abc[tmp])", "- # exit()", "- num = abc[tmp][i][0]", "+", "+", "+def dfs(p):", "+ for i in range(len(abc[p])):", "+ num = abc[p][i][0]", "- path[num] = path[tmp] + abc[tmp][i][1]", "- q.put(num)", "+ path[num] = path[p] + abc[p][i][1]", "+ dfs(num)", "+", "+", "+dfs(k)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3961623552, "measured_runtime_v1": 0.2607869017, "runtime_lift": 1.5191037302, "key": ["s279386500", "s990337521"]} {"user_id": "u164727245", "problem_id": "p02685", "language": "python", "submission_id_v0": "s549338354", "submission_id_v1": "s173586541", "cpu_time_v0": 842, "cpu_time_v1": 187, "memory_v0": 9192, "memory_v1": 16648, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 77.79, "input": "# coding: utf-8\n\n\n\n\n\ndef solve(*args: str) -> str:\n\n n, m, k = list(map(int, args[0].split()))\n\n mod = 998244353\n\n\n\n if m == 1 and n-1 == k:\n\n return str(1)\n\n\n\n ncr = 1\n\n p = m*pow(m-1, n-1, mod) % mod\n\n ret = p\n\n inv = pow(m-1, mod-2, mod)\n\n for i in range(1, k+1):\n\n ncr = (ncr * (n-i)*pow(i, mod-2, mod)) % mod\n\n p = (p*inv) % mod\n\n ret += p*ncr % mod\n\n\n\n return str(ret % mod)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n print((solve(*(open(0).read().splitlines()))))\n", "target": "# coding: utf-8\n\n\n\n\n\ndef solve(*args: str) -> str:\n\n n, m, k = list(map(int, args[0].split()))\n\n mod = 998244353\n\n\n\n if m == 1 and n-1 == k:\n\n return str(1)\n\n\n\n ncr = 1\n\n p = m*pow(m-1, n-1, mod) % mod\n\n\n\n ret = p\n\n iR = [1]*(k+1)\n\n im = pow(m-1, mod-2, mod)\n\n\n\n for i in range(1, k+1):\n\n iR[i] = max(1, (-(mod//i) * iR[mod % i]) % mod)\n\n ncr = (ncr * (n-i)*iR[i]) % mod\n\n p = (p*im) % mod\n\n ret += p*ncr % mod\n\n\n\n return str(ret % mod)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n print((solve(*(open(0).read().splitlines()))))\n", "code_v0_loc": 24, "code_v1_loc": 28, "code_v0_num_chars": 512, "code_v1_num_chars": 578, "code_v0_no_empty_lines": "# coding: utf-8\ndef solve(*args: str) -> str:\n n, m, k = list(map(int, args[0].split()))\n mod = 998244353\n if m == 1 and n - 1 == k:\n return str(1)\n ncr = 1\n p = m * pow(m - 1, n - 1, mod) % mod\n ret = p\n inv = pow(m - 1, mod - 2, mod)\n for i in range(1, k + 1):\n ncr = (ncr * (n - i) * pow(i, mod - 2, mod)) % mod\n p = (p * inv) % mod\n ret += p * ncr % mod\n return str(ret % mod)\n\n\nif __name__ == \"__main__\":\n print((solve(*(open(0).read().splitlines()))))\n", "code_v1_no_empty_lines": "# coding: utf-8\ndef solve(*args: str) -> str:\n n, m, k = list(map(int, args[0].split()))\n mod = 998244353\n if m == 1 and n - 1 == k:\n return str(1)\n ncr = 1\n p = m * pow(m - 1, n - 1, mod) % mod\n ret = p\n iR = [1] * (k + 1)\n im = pow(m - 1, mod - 2, mod)\n for i in range(1, k + 1):\n iR[i] = max(1, (-(mod // i) * iR[mod % i]) % mod)\n ncr = (ncr * (n - i) * iR[i]) % mod\n p = (p * im) % mod\n ret += p * ncr % mod\n return str(ret % mod)\n\n\nif __name__ == \"__main__\":\n print((solve(*(open(0).read().splitlines()))))\n", "code_same": false, "relative_loc_diff_percent": 14.2857142857, "diff": ["- inv = pow(m - 1, mod - 2, mod)", "+ iR = [1] * (k + 1)", "+ im = pow(m - 1, mod - 2, mod)", "- ncr = (ncr * (n - i) * pow(i, mod - 2, mod)) % mod", "- p = (p * inv) % mod", "+ iR[i] = max(1, (-(mod // i) * iR[mod % i]) % mod)", "+ ncr = (ncr * (n - i) * iR[i]) % mod", "+ p = (p * im) % mod"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4946005352, "measured_runtime_v1": 0.3604053538, "runtime_lift": 1.3723451385, "key": ["s549338354", "s173586541"]} {"user_id": "u054556734", "problem_id": "p03828", "language": "python", "submission_id_v0": "s442927172", "submission_id_v1": "s952876179", "cpu_time_v0": 83, "cpu_time_v1": 25, "memory_v0": 3316, "memory_v1": 3316, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 69.88, "input": "import collections as col\n\n\n\ndef prime(n):\n\n ans = []\n\n num = n\n\n for i in range(2,n+1):\n\n if i%2==0 and i!=2: continue\n\n while num%i == 0: num //= i ; ans.append(i)\n\n return ans\n\n\n\nn = int(input())\n\nmod = 10**9 + 7\n\n\n\nprimes = []\n\nfor i in range(2,n+1): primes += prime(i)\n\n\n\ncnt = col.Counter(primes)\n\nans = 1\n\nfor key,val in list(cnt.items()): ans *= (val + 1) ; ans %= mod\n\nprint(ans)\n", "target": "import collections as col\n\n\n\ndef prime(n):\n\n ans = []\n\n num = n\n\n for i in range(2,int(n**0.5)+1):\n\n if i%2==0 and i!=2: continue\n\n while num%i == 0: num //= i ; ans.append(i)\n\n if num != 1: ans.append(num)\n\n return ans\n\n\n\nn = int(input())\n\nmod = 10**9 + 7\n\n\n\nprimes = []\n\nfor i in range(2,n+1): primes += prime(i)\n\n\n\ncnt = col.Counter(primes)\n\nans = 1\n\nfor key,val in list(cnt.items()): ans *= (val + 1) ; ans %= mod\n\nprint(ans)\n", "code_v0_loc": 20, "code_v1_loc": 21, "code_v0_num_chars": 409, "code_v1_num_chars": 453, "code_v0_no_empty_lines": "import collections as col\n\n\ndef prime(n):\n ans = []\n num = n\n for i in range(2, n + 1):\n if i % 2 == 0 and i != 2:\n continue\n while num % i == 0:\n num //= i\n ans.append(i)\n return ans\n\n\nn = int(input())\nmod = 10**9 + 7\nprimes = []\nfor i in range(2, n + 1):\n primes += prime(i)\ncnt = col.Counter(primes)\nans = 1\nfor key, val in list(cnt.items()):\n ans *= val + 1\n ans %= mod\nprint(ans)\n", "code_v1_no_empty_lines": "import collections as col\n\n\ndef prime(n):\n ans = []\n num = n\n for i in range(2, int(n**0.5) + 1):\n if i % 2 == 0 and i != 2:\n continue\n while num % i == 0:\n num //= i\n ans.append(i)\n if num != 1:\n ans.append(num)\n return ans\n\n\nn = int(input())\nmod = 10**9 + 7\nprimes = []\nfor i in range(2, n + 1):\n primes += prime(i)\ncnt = col.Counter(primes)\nans = 1\nfor key, val in list(cnt.items()):\n ans *= val + 1\n ans %= mod\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 4.7619047619, "diff": ["- for i in range(2, n + 1):", "+ for i in range(2, int(n**0.5) + 1):", "+ if num != 1:", "+ ans.append(num)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3365422637, "measured_runtime_v1": 0.2564944384, "runtime_lift": 1.3120840585, "key": ["s442927172", "s952876179"]} {"user_id": "u440566786", "problem_id": "p03164", "language": "python", "submission_id_v0": "s415436180", "submission_id_v1": "s201445864", "cpu_time_v0": 345, "cpu_time_v1": 221, "memory_v0": 70988, "memory_v1": 40176, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 35.94, "input": "import sys\n\nsys.setrecursionlimit(2147483647)\n\nINF=float(\"inf\")\n\nMOD=10**9+7\n\ninput=lambda :sys.stdin.readline().rstrip()\n\ndef resolve():\n\n n,W=list(map(int,input().split()))\n\n WV=[tuple(map(int,input().split())) for _ in range(n)]\n\n\n\n V=100000\n\n dp=[INF]*(V+1)\n\n dp[0]=0\n\n\n\n for w,v in WV:\n\n for x in range(V,-1,-1):\n\n if(x+v<=V):\n\n dp[x+v]=min(dp[x+v],dp[x]+w)\n\n\n\n for x in range(V,-1,-1):\n\n if(dp[x]<=W):\n\n print(x)\n\n return\n\nresolve()", "target": "import sys\n\nINF = 1 << 60\n\nMOD = 10**9 + 7 # 998244353\n\nsys.setrecursionlimit(2147483647)\n\ninput = lambda:sys.stdin.readline().rstrip()\n\ndef resolve():\n\n n, W = list(map(int, input().split()))\n\n dp = [INF] * (n * 1001 + 1)\n\n dp[0] = 0\n\n for _ in range(n):\n\n w, v = list(map(int, input().split()))\n\n for v0 in range(n * 1001, -1, -1):\n\n if dp[v0] == INF:\n\n continue\n\n if v + v0 <= n * 1001:\n\n dp[v + v0] = min(dp[v + v0], dp[v0] + w)\n\n for v in range(n * 1001, -1, -1):\n\n if dp[v] <= W:\n\n print(v)\n\n return\n\nresolve()", "code_v0_loc": 23, "code_v1_loc": 21, "code_v0_num_chars": 515, "code_v1_num_chars": 614, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(2147483647)\nINF = float(\"inf\")\nMOD = 10**9 + 7\ninput = lambda: sys.stdin.readline().rstrip()\n\n\ndef resolve():\n n, W = list(map(int, input().split()))\n WV = [tuple(map(int, input().split())) for _ in range(n)]\n V = 100000\n dp = [INF] * (V + 1)\n dp[0] = 0\n for w, v in WV:\n for x in range(V, -1, -1):\n if x + v <= V:\n dp[x + v] = min(dp[x + v], dp[x] + w)\n for x in range(V, -1, -1):\n if dp[x] <= W:\n print(x)\n return\n\n\nresolve()\n", "code_v1_no_empty_lines": "import sys\n\nINF = 1 << 60\nMOD = 10**9 + 7 # 998244353\nsys.setrecursionlimit(2147483647)\ninput = lambda: sys.stdin.readline().rstrip()\n\n\ndef resolve():\n n, W = list(map(int, input().split()))\n dp = [INF] * (n * 1001 + 1)\n dp[0] = 0\n for _ in range(n):\n w, v = list(map(int, input().split()))\n for v0 in range(n * 1001, -1, -1):\n if dp[v0] == INF:\n continue\n if v + v0 <= n * 1001:\n dp[v + v0] = min(dp[v + v0], dp[v0] + w)\n for v in range(n * 1001, -1, -1):\n if dp[v] <= W:\n print(v)\n return\n\n\nresolve()\n", "code_same": false, "relative_loc_diff_percent": 8.6956521739, "diff": ["+INF = 1 << 60", "+MOD = 10**9 + 7 # 998244353", "-INF = float(\"inf\")", "-MOD = 10**9 + 7", "- WV = [tuple(map(int, input().split())) for _ in range(n)]", "- V = 100000", "- dp = [INF] * (V + 1)", "+ dp = [INF] * (n * 1001 + 1)", "- for w, v in WV:", "- for x in range(V, -1, -1):", "- if x + v <= V:", "- dp[x + v] = min(dp[x + v], dp[x] + w)", "- for x in range(V, -1, -1):", "- if dp[x] <= W:", "- print(x)", "+ for _ in range(n):", "+ w, v = list(map(int, input().split()))", "+ for v0 in range(n * 1001, -1, -1):", "+ if dp[v0] == INF:", "+ continue", "+ if v + v0 <= n * 1001:", "+ dp[v + v0] = min(dp[v + v0], dp[v0] + w)", "+ for v in range(n * 1001, -1, -1):", "+ if dp[v] <= W:", "+ print(v)"], "diff_only_import_comment": false, "measured_runtime_v0": 1.2692114379, "measured_runtime_v1": 0.2021781888, "runtime_lift": 6.2776872491, "key": ["s415436180", "s201445864"]} {"user_id": "u764956288", "problem_id": "p02691", "language": "python", "submission_id_v0": "s430506044", "submission_id_v1": "s372862352", "cpu_time_v0": 215, "cpu_time_v1": 188, "memory_v0": 57704, "memory_v1": 36612, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 12.56, "input": "from collections import defaultdict\n\n\n\n\n\ndef main():\n\n _ = int(input())\n\n heights = list(map(int, input().split()))\n\n\n\n \"\"\"\n\n for j>i, j-i = Ai + Aj\n\n i + Ai = j -Aj\n\n \"\"\"\n\n\n\n L = defaultdict(int)\n\n R = defaultdict(int)\n\n\n\n for i, height in enumerate(heights):\n\n L[i + height] += 1\n\n R[i - height] += 1\n\n\n\n total_count = 0\n\n for x, count_l in list(L.items()):\n\n if x in R:\n\n count_r = R[x]\n\n total_count += count_l * count_r\n\n\n\n print(total_count)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "target": "from collections import defaultdict\n\n\n\n\n\ndef main():\n\n N = int(input())\n\n heights = list(map(int, input().split()))\n\n\n\n \"\"\"\n\n for j>i, j-i = Ai + Aj\n\n i + Ai = j -Aj\n\n \"\"\"\n\n\n\n L = defaultdict(int)\n\n R = defaultdict(int)\n\n\n\n for i, height in enumerate(heights):\n\n if i + height < N:\n\n L[i + height] += 1\n\n \n\n if i - height > 0:\n\n R[i - height] += 1\n\n\n\n total_count = 0\n\n for x, count_l in list(L.items()):\n\n if x in R:\n\n count_r = R[x]\n\n total_count += count_l * count_r\n\n\n\n print(total_count)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()\n", "code_v0_loc": 30, "code_v1_loc": 33, "code_v0_num_chars": 565, "code_v1_num_chars": 639, "code_v0_no_empty_lines": "from collections import defaultdict\n\n\ndef main():\n _ = int(input())\n heights = list(map(int, input().split()))\n \"\"\"\n for j>i, j-i = Ai + Aj\n i + Ai = j -Aj\n \"\"\"\n L = defaultdict(int)\n R = defaultdict(int)\n for i, height in enumerate(heights):\n L[i + height] += 1\n R[i - height] += 1\n total_count = 0\n for x, count_l in list(L.items()):\n if x in R:\n count_r = R[x]\n total_count += count_l * count_r\n print(total_count)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "from collections import defaultdict\n\n\ndef main():\n N = int(input())\n heights = list(map(int, input().split()))\n \"\"\"\n for j>i, j-i = Ai + Aj\n i + Ai = j -Aj\n \"\"\"\n L = defaultdict(int)\n R = defaultdict(int)\n for i, height in enumerate(heights):\n if i + height < N:\n L[i + height] += 1\n if i - height > 0:\n R[i - height] += 1\n total_count = 0\n for x, count_l in list(L.items()):\n if x in R:\n count_r = R[x]\n total_count += count_l * count_r\n print(total_count)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 9.0909090909, "diff": ["- _ = int(input())", "+ N = int(input())", "- L[i + height] += 1", "- R[i - height] += 1", "+ if i + height < N:", "+ L[i + height] += 1", "+ if i - height > 0:", "+ R[i - height] += 1"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3616042199, "measured_runtime_v1": 0.2114392846, "runtime_lift": 1.7102035728, "key": ["s430506044", "s372862352"]} {"user_id": "u747602774", "problem_id": "p03039", "language": "python", "submission_id_v0": "s387237372", "submission_id_v1": "s322645394", "cpu_time_v0": 230, "cpu_time_v1": 47, "memory_v0": 9412, "memory_v1": 9476, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 79.57, "input": "import sys\n\nreadline = sys.stdin.readline\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\n#mod = 998244353\n\nINF = 10**18\n\neps = 10**-7\n\n\n\nm,n,k = list(map(int,readline().split()))\n\n\n\ndef comb(n, r, mod):\n\n r = min(r, n-r)\n\n mol = 1\n\n deno = 1\n\n for i in range(1, r+1):\n\n mol = mol * (n-r+i) % mod\n\n deno = deno * i % mod\n\n ret = mol * pow(deno, mod-2, mod) % mod\n\n return ret\n\n\n\ndef f1(x,y,a,b):\n\n return (a+b-x-y)*(a-x+1)*(b-y+1)//2\n\n\n\ndef f2(x,a):\n\n return (a-x)*(a-x+1)//2\n\n\n\nans = 0\n\n\n\nfor x in range(1,n+1):\n\n for y in range(1,m+1):\n\n a = n-x+1\n\n b = m-y+1\n\n c = m*(a*(a-1)+x*(x-1))\n\n d = n*(b*(b-1)+y*(y-1))\n\n ans += (c+d)//2\n\n ans %= mod\n\n\n\nans = (ans * comb(m*n-2,k-2,mod))%mod\n\nans = ans*pow(2,mod-2,mod)%mod\n\n\n\nprint(ans)\n\n\n", "target": "import sys\n\nreadline = sys.stdin.readline\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\n#mod = 998244353\n\nINF = 10**18\n\neps = 10**-7\n\n\n\nm,n,k = list(map(int,readline().split()))\n\n\n\ndef comb(n, r, mod):\n\n r = min(r, n-r)\n\n mol = 1\n\n deno = 1\n\n for i in range(1, r+1):\n\n mol = mol * (n-r+i) % mod\n\n deno = deno * i % mod\n\n ret = mol * pow(deno, mod-2, mod) % mod\n\n return ret\n\n\n\nans = m*n*(m+n)*(m*n-1)//3\n\n\n\nans = (ans * comb(m*n-2,k-2,mod))%mod\n\nans = ans*pow(2,mod-2,mod)%mod\n\n\n\nprint(ans)\n\n\n", "code_v0_loc": 42, "code_v1_loc": 27, "code_v0_num_chars": 809, "code_v1_num_chars": 519, "code_v0_no_empty_lines": "import sys\n\nreadline = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\n# mod = 998244353\nINF = 10**18\neps = 10**-7\nm, n, k = list(map(int, readline().split()))\n\n\ndef comb(n, r, mod):\n r = min(r, n - r)\n mol = 1\n deno = 1\n for i in range(1, r + 1):\n mol = mol * (n - r + i) % mod\n deno = deno * i % mod\n ret = mol * pow(deno, mod - 2, mod) % mod\n return ret\n\n\ndef f1(x, y, a, b):\n return (a + b - x - y) * (a - x + 1) * (b - y + 1) // 2\n\n\ndef f2(x, a):\n return (a - x) * (a - x + 1) // 2\n\n\nans = 0\nfor x in range(1, n + 1):\n for y in range(1, m + 1):\n a = n - x + 1\n b = m - y + 1\n c = m * (a * (a - 1) + x * (x - 1))\n d = n * (b * (b - 1) + y * (y - 1))\n ans += (c + d) // 2\n ans %= mod\nans = (ans * comb(m * n - 2, k - 2, mod)) % mod\nans = ans * pow(2, mod - 2, mod) % mod\nprint(ans)\n", "code_v1_no_empty_lines": "import sys\n\nreadline = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\n# mod = 998244353\nINF = 10**18\neps = 10**-7\nm, n, k = list(map(int, readline().split()))\n\n\ndef comb(n, r, mod):\n r = min(r, n - r)\n mol = 1\n deno = 1\n for i in range(1, r + 1):\n mol = mol * (n - r + i) % mod\n deno = deno * i % mod\n ret = mol * pow(deno, mod - 2, mod) % mod\n return ret\n\n\nans = m * n * (m + n) * (m * n - 1) // 3\nans = (ans * comb(m * n - 2, k - 2, mod)) % mod\nans = ans * pow(2, mod - 2, mod) % mod\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 35.7142857143, "diff": ["-def f1(x, y, a, b):", "- return (a + b - x - y) * (a - x + 1) * (b - y + 1) // 2", "-", "-", "-def f2(x, a):", "- return (a - x) * (a - x + 1) // 2", "-", "-", "-ans = 0", "-for x in range(1, n + 1):", "- for y in range(1, m + 1):", "- a = n - x + 1", "- b = m - y + 1", "- c = m * (a * (a - 1) + x * (x - 1))", "- d = n * (b * (b - 1) + y * (y - 1))", "- ans += (c + d) // 2", "- ans %= mod", "+ans = m * n * (m + n) * (m * n - 1) // 3"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3618569455, "measured_runtime_v1": 0.2781652772, "runtime_lift": 1.3008702923, "key": ["s387237372", "s322645394"]} {"user_id": "u800396927", "problem_id": "p03253", "language": "python", "submission_id_v0": "s723979708", "submission_id_v1": "s327831897", "cpu_time_v0": 110, "cpu_time_v1": 67, "memory_v0": 10868, "memory_v1": 66752, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 39.09, "input": "N,M = list(map(int,input().split()))\n\ndiv =[]\n\nfor i in range(2,int(M**(1/2))+2):\n\n cur = 0\n\n while M%i==0:\n\n M = M//i\n\n cur += 1\n\n if cur >=1:\n\n div.append(cur)\n\nif M>1: div.append(1)\n\ndiv.sort()\n\nmod = 10**9+7\n\nfrac = [1]*(N+50)\n\nnum = len(frac)\n\nfor i in range(len(frac)-1):\n\n frac[i+1] = frac[i]*(i+1)%mod\n\nfinv = [1] * (N+50)\n\nfinv[-1] = pow(frac[-1], mod-2, mod)\n\nfor i in range(1, num):\n\n finv[num-1-i] = finv[num-i] * (num-i) % mod\n\nans = 1\n\nfor i in div:\n\n ans = ans * frac[N+i-1]*finv[N-1]*finv[i]%mod\n\nprint(ans)", "target": "N,M = list(map(int,input().split()))\n\ndiv = []\n\nfor i in range(2,int(M**(1/2))+2):\n\n cur = 0\n\n while M%i==0:\n\n M//=i\n\n cur += 1\n\n if cur >=1:\n\n div.append(cur)\n\nif M>1:div.append(1)\n\ndiv.sort()\n\nmod = 10**9+7\n\nfrac = [1]*(N+50)\n\nnum=len(frac)\n\nfor i in range(num-1):\n\n frac[i+1] = frac[i]*(i+1)%mod\n\nfinv = [1]*(N+50)\n\nfinv[-1] = pow(frac[-1],mod-2,mod)\n\nans = 1\n\nfor i in range(1,num):\n\n finv[num-1-i] = finv[num-i]*(num-i)%mod\n\nfor i in div:\n\n ans =ans*frac[N+i-1]*finv[N-1]*finv[i]%mod\n\nprint(ans)", "code_v0_loc": 24, "code_v1_loc": 24, "code_v0_num_chars": 554, "code_v1_num_chars": 534, "code_v0_no_empty_lines": "N, M = list(map(int, input().split()))\ndiv = []\nfor i in range(2, int(M ** (1 / 2)) + 2):\n cur = 0\n while M % i == 0:\n M = M // i\n cur += 1\n if cur >= 1:\n div.append(cur)\nif M > 1:\n div.append(1)\ndiv.sort()\nmod = 10**9 + 7\nfrac = [1] * (N + 50)\nnum = len(frac)\nfor i in range(len(frac) - 1):\n frac[i + 1] = frac[i] * (i + 1) % mod\nfinv = [1] * (N + 50)\nfinv[-1] = pow(frac[-1], mod - 2, mod)\nfor i in range(1, num):\n finv[num - 1 - i] = finv[num - i] * (num - i) % mod\nans = 1\nfor i in div:\n ans = ans * frac[N + i - 1] * finv[N - 1] * finv[i] % mod\nprint(ans)\n", "code_v1_no_empty_lines": "N, M = list(map(int, input().split()))\ndiv = []\nfor i in range(2, int(M ** (1 / 2)) + 2):\n cur = 0\n while M % i == 0:\n M //= i\n cur += 1\n if cur >= 1:\n div.append(cur)\nif M > 1:\n div.append(1)\ndiv.sort()\nmod = 10**9 + 7\nfrac = [1] * (N + 50)\nnum = len(frac)\nfor i in range(num - 1):\n frac[i + 1] = frac[i] * (i + 1) % mod\nfinv = [1] * (N + 50)\nfinv[-1] = pow(frac[-1], mod - 2, mod)\nans = 1\nfor i in range(1, num):\n finv[num - 1 - i] = finv[num - i] * (num - i) % mod\nfor i in div:\n ans = ans * frac[N + i - 1] * finv[N - 1] * finv[i] % mod\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- M = M // i", "+ M //= i", "-for i in range(len(frac) - 1):", "+for i in range(num - 1):", "+ans = 1", "-ans = 1"], "diff_only_import_comment": false, "measured_runtime_v0": 0.47082161, "measured_runtime_v1": 0.3749034932, "runtime_lift": 1.2558474875, "key": ["s723979708", "s327831897"]} {"user_id": "u290563917", "problem_id": "p03371", "language": "python", "submission_id_v0": "s511736682", "submission_id_v1": "s377839923", "cpu_time_v0": 188, "cpu_time_v1": 64, "memory_v0": 40940, "memory_v1": 65396, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 65.96, "input": "a, b, c, x, y = list(map(int, input().split()))\n\n# print(a, b, c, x, y)\n\n\n\nans = 10000 * (10 **5) + 7\n\nc_max = 0\n\nif x > y:\n\n c_max = x * 2\n\nelse:\n\n c_max = y * 2\n\n\n\nfor cc in range(c_max+1):\n\n ac = x - (cc // 2)\n\n bc = y - (cc // 2)\n\n \n\n if ac < 0:\n\n ac = 0\n\n if bc < 0:\n\n bc = 0\n\n price = ac * a + bc * b + cc * c\n\n # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))\n\n ans = min(ans, price)\n\n\n\nprint(ans)", "target": "a, b, c, x, y = list(map(int, input().split()))\n\n# print(a, b, c, x, y)\n\n\n\nans = 10000 * (10 **5) + 7\n\nc_max = 0\n\nif x > y:\n\n c_max = x * 2\n\nelse:\n\n c_max = y * 2\n\n\n\nfor cc in range(0, c_max+1, 2):\n\n ac = x - (cc // 2)\n\n bc = y - (cc // 2)\n\n \n\n if ac < 0:\n\n ac = 0\n\n if bc < 0:\n\n bc = 0\n\n price = ac * a + bc * b + cc * c\n\n # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))\n\n ans = min(ans, price)\n\n\n\nprint(ans)\n\n ", "code_v0_loc": 23, "code_v1_loc": 24, "code_v0_num_chars": 436, "code_v1_num_chars": 446, "code_v0_no_empty_lines": "a, b, c, x, y = list(map(int, input().split()))\n# print(a, b, c, x, y)\nans = 10000 * (10**5) + 7\nc_max = 0\nif x > y:\n c_max = x * 2\nelse:\n c_max = y * 2\nfor cc in range(c_max + 1):\n ac = x - (cc // 2)\n bc = y - (cc // 2)\n if ac < 0:\n ac = 0\n if bc < 0:\n bc = 0\n price = ac * a + bc * b + cc * c\n # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))\n ans = min(ans, price)\nprint(ans)\n", "code_v1_no_empty_lines": "a, b, c, x, y = list(map(int, input().split()))\n# print(a, b, c, x, y)\nans = 10000 * (10**5) + 7\nc_max = 0\nif x > y:\n c_max = x * 2\nelse:\n c_max = y * 2\nfor cc in range(0, c_max + 1, 2):\n ac = x - (cc // 2)\n bc = y - (cc // 2)\n if ac < 0:\n ac = 0\n if bc < 0:\n bc = 0\n price = ac * a + bc * b + cc * c\n # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))\n ans = min(ans, price)\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 4.1666666667, "diff": ["-for cc in range(c_max + 1):", "+for cc in range(0, c_max + 1, 2):"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4004499781, "measured_runtime_v1": 0.3093135242, "runtime_lift": 1.2946410251, "key": ["s511736682", "s377839923"]} {"user_id": "u887207211", "problem_id": "p03425", "language": "python", "submission_id_v0": "s819679830", "submission_id_v1": "s546088432", "cpu_time_v0": 172, "cpu_time_v1": 153, "memory_v0": 3064, "memory_v1": 9752, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 11.05, "input": "N = int(input())\n\nname = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}\n\nmarch = \"MARCH\"\n\nfor _ in range(N):\n\n S = input()\n\n if(S[0] in name):\n\n name[S[0]] += 1\n\nans = 0\n\nfor i in range(3):\n\n for j in range(i+1,4):\n\n for k in range(j+1,5):\n\n ans += name[march[i]] * name[march[j]] * name[march[k]]\n\nprint(ans)", "target": "N = int(input())\n\nS = [input() for _ in range(N)]\n\n\n\nhead = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}\n\nmarch = \"MARCH\"\n\nfor s in S:\n\n if(s[0] in head):\n\n head[s[0]] += 1\n\nans = 0\n\nfor i in range(3):\n\n for j in range(i+1,4):\n\n for k in range(j+1,5):\n\n ans += head[march[i]] * head[march[j]] * head[march[k]]\n\nprint(ans)", "code_v0_loc": 13, "code_v1_loc": 14, "code_v0_num_chars": 312, "code_v1_num_chars": 325, "code_v0_no_empty_lines": "N = int(input())\nname = {\"M\": 0, \"A\": 0, \"R\": 0, \"C\": 0, \"H\": 0}\nmarch = \"MARCH\"\nfor _ in range(N):\n S = input()\n if S[0] in name:\n name[S[0]] += 1\nans = 0\nfor i in range(3):\n for j in range(i + 1, 4):\n for k in range(j + 1, 5):\n ans += name[march[i]] * name[march[j]] * name[march[k]]\nprint(ans)\n", "code_v1_no_empty_lines": "N = int(input())\nS = [input() for _ in range(N)]\nhead = {\"M\": 0, \"A\": 0, \"R\": 0, \"C\": 0, \"H\": 0}\nmarch = \"MARCH\"\nfor s in S:\n if s[0] in head:\n head[s[0]] += 1\nans = 0\nfor i in range(3):\n for j in range(i + 1, 4):\n for k in range(j + 1, 5):\n ans += head[march[i]] * head[march[j]] * head[march[k]]\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 7.1428571429, "diff": ["-name = {\"M\": 0, \"A\": 0, \"R\": 0, \"C\": 0, \"H\": 0}", "+S = [input() for _ in range(N)]", "+head = {\"M\": 0, \"A\": 0, \"R\": 0, \"C\": 0, \"H\": 0}", "-for _ in range(N):", "- S = input()", "- if S[0] in name:", "- name[S[0]] += 1", "+for s in S:", "+ if s[0] in head:", "+ head[s[0]] += 1", "- ans += name[march[i]] * name[march[j]] * name[march[k]]", "+ ans += head[march[i]] * head[march[j]] * head[march[k]]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4009393435, "measured_runtime_v1": 0.3106073449, "runtime_lift": 1.2908237686, "key": ["s819679830", "s546088432"]} {"user_id": "u463655976", "problem_id": "p03013", "language": "python", "submission_id_v0": "s227334045", "submission_id_v1": "s524241188", "cpu_time_v0": 285, "cpu_time_v1": 189, "memory_v0": 22940, "memory_v1": 7836, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 33.68, "input": "from functools import lru_cache\n\nimport sys\n\nsys.setrecursionlimit(30000)\n\n\n\nN, M = list(map(int, input().split()))\n\na = list(int(input()) for _ in range(M))\n\n\n\nMOD = pow(10, 9) + 7\n\n\n\nisOk = True\n\nfor i in range(M-1):\n\n if a[i] + 1 == a[i+1]:\n\n isOk = False\n\n \n\nfuncb = [-1] * 100001\n\ndef func(n):\n\n if n <= 0:\n\n return 1\n\n cnt = funcb[n]\n\n if cnt > 0:\n\n return cnt\n\n cnt = 0\n\n if n >= 2:\n\n cnt += func(n-2)\n\n if n >= 1:\n\n cnt += func(n-1)\n\n funcb[n] = cnt % MOD\n\n return funcb[n]\n\n\n\nfunc(30000)\n\nfunc(50000)\n\nfunc(80000)\n\nfunc(100000)\n\n\n\nif not isOk:\n\n print((0))\n\nelse:\n\n ans = 1\n\n s = 0\n\n for i in range(M+1):\n\n if i >= M:\n\n e = N\n\n else:\n\n e = a[i] - 1\n\n\n\n ans = ans * func(e-s) % MOD\n\n\n\n if i >= M:\n\n break\n\n\n\n s = a[i] + 1\n\n\n\n print(ans)\n", "target": "N, M = list(map(int, input().split()))\n\na = list(int(input()) for _ in range(M))\n\n\n\nMOD = pow(10, 9) + 7\n\n\n\nMAP = [0] * (N + 1)\n\n\n\nfor x in a:\n\n MAP[x] = -1\n\n\n\nMAP[0] = 1 \n\nfor i in range(N):\n\n if MAP[i] < 0:\n\n continue\n\n\n\n MAP[i] %= MOD\n\n if i + 1 <= N and MAP[i+1] >= 0:\n\n MAP[i+1] += MAP[i]\n\n if i + 2 <= N and MAP[i+2] >= 0:\n\n MAP[i+2] += MAP[i]\n\n\n\nprint((MAP[N] % MOD))\n", "code_v0_loc": 53, "code_v1_loc": 22, "code_v0_num_chars": 885, "code_v1_num_chars": 403, "code_v0_no_empty_lines": "from functools import lru_cache\nimport sys\n\nsys.setrecursionlimit(30000)\nN, M = list(map(int, input().split()))\na = list(int(input()) for _ in range(M))\nMOD = pow(10, 9) + 7\nisOk = True\nfor i in range(M - 1):\n if a[i] + 1 == a[i + 1]:\n isOk = False\nfuncb = [-1] * 100001\n\n\ndef func(n):\n if n <= 0:\n return 1\n cnt = funcb[n]\n if cnt > 0:\n return cnt\n cnt = 0\n if n >= 2:\n cnt += func(n - 2)\n if n >= 1:\n cnt += func(n - 1)\n funcb[n] = cnt % MOD\n return funcb[n]\n\n\nfunc(30000)\nfunc(50000)\nfunc(80000)\nfunc(100000)\nif not isOk:\n print((0))\nelse:\n ans = 1\n s = 0\n for i in range(M + 1):\n if i >= M:\n e = N\n else:\n e = a[i] - 1\n ans = ans * func(e - s) % MOD\n if i >= M:\n break\n s = a[i] + 1\n print(ans)\n", "code_v1_no_empty_lines": "N, M = list(map(int, input().split()))\na = list(int(input()) for _ in range(M))\nMOD = pow(10, 9) + 7\nMAP = [0] * (N + 1)\nfor x in a:\n MAP[x] = -1\nMAP[0] = 1\nfor i in range(N):\n if MAP[i] < 0:\n continue\n MAP[i] %= MOD\n if i + 1 <= N and MAP[i + 1] >= 0:\n MAP[i + 1] += MAP[i]\n if i + 2 <= N and MAP[i + 2] >= 0:\n MAP[i + 2] += MAP[i]\nprint((MAP[N] % MOD))\n", "code_same": false, "relative_loc_diff_percent": 58.4905660377, "diff": ["-from functools import lru_cache", "-import sys", "-", "-sys.setrecursionlimit(30000)", "-isOk = True", "-for i in range(M - 1):", "- if a[i] + 1 == a[i + 1]:", "- isOk = False", "-funcb = [-1] * 100001", "-", "-", "-def func(n):", "- if n <= 0:", "- return 1", "- cnt = funcb[n]", "- if cnt > 0:", "- return cnt", "- cnt = 0", "- if n >= 2:", "- cnt += func(n - 2)", "- if n >= 1:", "- cnt += func(n - 1)", "- funcb[n] = cnt % MOD", "- return funcb[n]", "-", "-", "-func(30000)", "-func(50000)", "-func(80000)", "-func(100000)", "-if not isOk:", "- print((0))", "-else:", "- ans = 1", "- s = 0", "- for i in range(M + 1):", "- if i >= M:", "- e = N", "- else:", "- e = a[i] - 1", "- ans = ans * func(e - s) % MOD", "- if i >= M:", "- break", "- s = a[i] + 1", "- print(ans)", "+MAP = [0] * (N + 1)", "+for x in a:", "+ MAP[x] = -1", "+MAP[0] = 1", "+for i in range(N):", "+ if MAP[i] < 0:", "+ continue", "+ MAP[i] %= MOD", "+ if i + 1 <= N and MAP[i + 1] >= 0:", "+ MAP[i + 1] += MAP[i]", "+ if i + 2 <= N and MAP[i + 2] >= 0:", "+ MAP[i + 2] += MAP[i]", "+print((MAP[N] % MOD))"], "diff_only_import_comment": false, "measured_runtime_v0": 1.0640589638, "measured_runtime_v1": 0.2648930094, "runtime_lift": 4.0169386351, "key": ["s227334045", "s524241188"]} {"user_id": "u254871849", "problem_id": "p03416", "language": "python", "submission_id_v0": "s286428945", "submission_id_v1": "s838954646", "cpu_time_v0": 41, "cpu_time_v1": 20, "memory_v0": 2940, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 51.22, "input": "# author: kagemeka \n\n# created: 2019-11-06 21:30:22(JST)\n\nimport sys\n\n# import collections\n\n# import math\n\n# import string\n\n# import bisect\n\n# import re\n\n# import itertools\n\n# import statistics\n\n# import functools\n\n# import operator\n\n\n\ndef main():\n\n a, b = (int(x) for x in sys.stdin.read().split())\n\n\n\n count = 0\n\n for n in range(a, b+1):\n\n n = str(n)\n\n if n == n[::-1]:\n\n count += 1\n\n\n\n print(count) \n\n\n\nif __name__ == \"__main__\":\n\n # execute only if run as a script\n\n main()\n", "target": "import sys\n\nfrom bisect import bisect_left as bi_l, bisect_right as bi_r\n\n\n\na, b = list(map(int, sys.stdin.readline().split()))\n\n\n\ndef main():\n\n palindromic_nums = []\n\n for i in range(1, 10):\n\n for j in range(10):\n\n for k in range(10):\n\n x = [i, j, k, j, i]\n\n palindromic_nums.append(int(''.join(list(map(str, x)))))\n\n\n\n return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a)\n\n \n\nif __name__ == '__main__':\n\n ans = main()\n\n print(ans)", "code_v0_loc": 27, "code_v1_loc": 18, "code_v0_num_chars": 576, "code_v1_num_chars": 512, "code_v0_no_empty_lines": "# author: kagemeka\n# created: 2019-11-06 21:30:22(JST)\nimport sys\n\n# import collections\n# import math\n# import string\n# import bisect\n# import re\n# import itertools\n# import statistics\n# import functools\n# import operator\ndef main():\n a, b = (int(x) for x in sys.stdin.read().split())\n count = 0\n for n in range(a, b + 1):\n n = str(n)\n if n == n[::-1]:\n count += 1\n print(count)\n\n\nif __name__ == \"__main__\":\n # execute only if run as a script\n main()\n", "code_v1_no_empty_lines": "import sys\nfrom bisect import bisect_left as bi_l, bisect_right as bi_r\n\na, b = list(map(int, sys.stdin.readline().split()))\n\n\ndef main():\n palindromic_nums = []\n for i in range(1, 10):\n for j in range(10):\n for k in range(10):\n x = [i, j, k, j, i]\n palindromic_nums.append(int(\"\".join(list(map(str, x)))))\n return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a)\n\n\nif __name__ == \"__main__\":\n ans = main()\n print(ans)\n", "code_same": false, "relative_loc_diff_percent": 33.3333333333, "diff": ["-# author: kagemeka", "-# created: 2019-11-06 21:30:22(JST)", "+from bisect import bisect_left as bi_l, bisect_right as bi_r", "-# import collections", "-# import math", "-# import string", "-# import bisect", "-# import re", "-# import itertools", "-# import statistics", "-# import functools", "-# import operator", "+a, b = list(map(int, sys.stdin.readline().split()))", "+", "+", "- a, b = (int(x) for x in sys.stdin.read().split())", "- count = 0", "- for n in range(a, b + 1):", "- n = str(n)", "- if n == n[::-1]:", "- count += 1", "- print(count)", "+ palindromic_nums = []", "+ for i in range(1, 10):", "+ for j in range(10):", "+ for k in range(10):", "+ x = [i, j, k, j, i]", "+ palindromic_nums.append(int(\"\".join(list(map(str, x)))))", "+ return bi_r(palindromic_nums, b) - bi_l(palindromic_nums, a)", "- # execute only if run as a script", "- main()", "+ ans = main()", "+ print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2528932301, "measured_runtime_v1": 0.1923888798, "runtime_lift": 1.314489852, "key": ["s286428945", "s838954646"]} {"user_id": "u157020659", "problem_id": "p02837", "language": "python", "submission_id_v0": "s547554870", "submission_id_v1": "s193607306", "cpu_time_v0": 585, "cpu_time_v1": 283, "memory_v0": 3064, "memory_v1": 18356, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 51.62, "input": "def check(x, y):\n\n for a, b in zip(x, y):\n\n if a != b and b != -1:\n\n return False\n\n else:\n\n return True\n\n\n\n\n\nn = int(input())\n\nremarks = []\n\ncnt_max = 0\n\nfor _ in range(n):\n\n a = int(input())\n\n x = [tuple(map(int, input().split())) for i in range(a)]\n\n r = [-1] * n\n\n for i, j in x:\n\n r[i - 1] = j\n\n remarks.append(r)\n\nfor r in range(2 ** n):\n\n r = list(bin(r)[2:].zfill(n))\n\n r = [int(i) for i in r[:]]\n\n cnt = 0\n\n for i in range(n):\n\n if r[i] == 1:\n\n flag = check(r, remarks[i])\n\n cnt += 1\n\n if not flag:\n\n cnt = 0\n\n break\n\n cnt_max = max(cnt, cnt_max)\n\nprint(cnt_max)", "target": "import numpy as np\n\nimport itertools\n\n\n\nn = int(input())\n\ninfo = []\n\nfor i in range(n):\n\n a = int(input())\n\n for _ in range(a):\n\n x, y = list(map(int, input().split()))\n\n info.append((i, x - 1, y))\n\n\n\na = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool)\n\nfor i, x, y in info:\n\n bl = (~a[:, i]) | (a[:, x] == bool(y))\n\n a = a[bl]\n\n\n\nans = a.sum(axis=1).max()\n\nprint(ans)", "code_v0_loc": 31, "code_v1_loc": 18, "code_v0_num_chars": 708, "code_v1_num_chars": 407, "code_v0_no_empty_lines": "def check(x, y):\n for a, b in zip(x, y):\n if a != b and b != -1:\n return False\n else:\n return True\n\n\nn = int(input())\nremarks = []\ncnt_max = 0\nfor _ in range(n):\n a = int(input())\n x = [tuple(map(int, input().split())) for i in range(a)]\n r = [-1] * n\n for i, j in x:\n r[i - 1] = j\n remarks.append(r)\nfor r in range(2**n):\n r = list(bin(r)[2:].zfill(n))\n r = [int(i) for i in r[:]]\n cnt = 0\n for i in range(n):\n if r[i] == 1:\n flag = check(r, remarks[i])\n cnt += 1\n if not flag:\n cnt = 0\n break\n cnt_max = max(cnt, cnt_max)\nprint(cnt_max)\n", "code_v1_no_empty_lines": "import numpy as np\nimport itertools\n\nn = int(input())\ninfo = []\nfor i in range(n):\n a = int(input())\n for _ in range(a):\n x, y = list(map(int, input().split()))\n info.append((i, x - 1, y))\na = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool)\nfor i, x, y in info:\n bl = (~a[:, i]) | (a[:, x] == bool(y))\n a = a[bl]\nans = a.sum(axis=1).max()\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 41.935483871, "diff": ["-def check(x, y):", "- for a, b in zip(x, y):", "- if a != b and b != -1:", "- return False", "- else:", "- return True", "-", "+import numpy as np", "+import itertools", "-remarks = []", "-cnt_max = 0", "-for _ in range(n):", "+info = []", "+for i in range(n):", "- x = [tuple(map(int, input().split())) for i in range(a)]", "- r = [-1] * n", "- for i, j in x:", "- r[i - 1] = j", "- remarks.append(r)", "-for r in range(2**n):", "- r = list(bin(r)[2:].zfill(n))", "- r = [int(i) for i in r[:]]", "- cnt = 0", "- for i in range(n):", "- if r[i] == 1:", "- flag = check(r, remarks[i])", "- cnt += 1", "- if not flag:", "- cnt = 0", "- break", "- cnt_max = max(cnt, cnt_max)", "-print(cnt_max)", "+ for _ in range(a):", "+ x, y = list(map(int, input().split()))", "+ info.append((i, x - 1, y))", "+a = np.array(list(itertools.product([0, 1], repeat=n)), dtype=np.bool)", "+for i, x, y in info:", "+ bl = (~a[:, i]) | (a[:, x] == bool(y))", "+ a = a[bl]", "+ans = a.sum(axis=1).max()", "+print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.1805458875, "measured_runtime_v1": 0.0064015586, "runtime_lift": 28.2034262917, "key": ["s547554870", "s193607306"]} {"user_id": "u645250356", "problem_id": "p02881", "language": "python", "submission_id_v0": "s106501170", "submission_id_v1": "s046181145", "cpu_time_v0": 232, "cpu_time_v1": 205, "memory_v0": 43632, "memory_v1": 40808, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 11.64, "input": "from collections import Counter,defaultdict,deque\n\nimport sys,bisect,math,itertools,string,queue\n\nfrom heapq import heappop, heappush\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef inpl_str(): return list(sys.stdin.readline().split())\n\ndef inpln(n): return list(int(sys.stdin.readline()) for i in range(n))\n\n\n\nn = inp()\n\nres = float('inf')\n\nfor i in range(1,2*10**6):\n\n if (n/i).is_integer():\n\n res = min(res, i + n/i)\n\nprint((int(res-2)))\n", "target": "from collections import Counter,defaultdict,deque\n\nimport sys,bisect,math,itertools,string,queue\n\nfrom heapq import heappop, heappush\n\nsys.setrecursionlimit(10**8)\n\nmod = 10**9+7\n\ndef inp(): return int(sys.stdin.readline())\n\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef inpl_str(): return list(sys.stdin.readline().split())\n\ndef inpln(n): return list(int(sys.stdin.readline()) for i in range(n))\n\n\n\nn = inp()\n\nres = float('inf')\n\nfor i in range(1,int(math.sqrt(n))+1):\n\n if n%i == 0:\n\n res = min(res, i + n/i)\n\nprint((int(res-2)))\n", "code_v0_loc": 16, "code_v1_loc": 16, "code_v0_num_chars": 561, "code_v1_num_chars": 563, "code_v0_no_empty_lines": "from collections import Counter, defaultdict, deque\nimport sys, bisect, math, itertools, string, queue\nfrom heapq import heappop, heappush\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef inpl_str():\n return list(sys.stdin.readline().split())\n\n\ndef inpln(n):\n return list(int(sys.stdin.readline()) for i in range(n))\n\n\nn = inp()\nres = float(\"inf\")\nfor i in range(1, 2 * 10**6):\n if (n / i).is_integer():\n res = min(res, i + n / i)\nprint((int(res - 2)))\n", "code_v1_no_empty_lines": "from collections import Counter, defaultdict, deque\nimport sys, bisect, math, itertools, string, queue\nfrom heapq import heappop, heappush\n\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\n\n\ndef inp():\n return int(sys.stdin.readline())\n\n\ndef inpl():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef inpl_str():\n return list(sys.stdin.readline().split())\n\n\ndef inpln(n):\n return list(int(sys.stdin.readline()) for i in range(n))\n\n\nn = inp()\nres = float(\"inf\")\nfor i in range(1, int(math.sqrt(n)) + 1):\n if n % i == 0:\n res = min(res, i + n / i)\nprint((int(res - 2)))\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["-for i in range(1, 2 * 10**6):", "- if (n / i).is_integer():", "+for i in range(1, int(math.sqrt(n)) + 1):", "+ if n % i == 0:"], "diff_only_import_comment": false, "measured_runtime_v0": 1.4036093347, "measured_runtime_v1": 0.1584749897, "runtime_lift": 8.856976976, "key": ["s106501170", "s046181145"]} {"user_id": "u325956328", "problem_id": "p02555", "language": "python", "submission_id_v0": "s422627112", "submission_id_v1": "s801844924", "cpu_time_v0": 468, "cpu_time_v1": 62, "memory_v0": 9136, "memory_v1": 9124, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 86.75, "input": "S = int(input())\n\n\n\ndp = [0] * (S + 1)\n\ndp[0] = 1\n\nM = 10 ** 9 + 7\n\n\n\nfor i in range(1, S + 1):\n\n num = 0\n\n for j in range(i - 2):\n\n num += dp[j]\n\n dp[i] = num % M\n\n\n\nprint((dp[S]))\n\n\n", "target": "S = int(input())\n\n\n\n\n\ndef cmb(n, r, p):\n\n r = min(n - r, r)\n\n if r == 0:\n\n return 1\n\n over = 1\n\n for i in range(n, n - r, -1):\n\n over = over * i % p\n\n under = 1\n\n for i in range(1, r + 1):\n\n under = under * i % p\n\n inv = pow(under, p - 2, p)\n\n return over * inv % p\n\n\n\n\n\nM = 10 ** 9 + 7\n\nans = 0\n\nfor i in range(1, S):\n\n if S - 3 * i < 0:\n\n break\n\n ans += cmb(S - 3 * i + i - 1, i - 1, M)\n\n ans %= M\n\nprint(ans)\n", "code_v0_loc": 14, "code_v1_loc": 25, "code_v0_num_chars": 202, "code_v1_num_chars": 473, "code_v0_no_empty_lines": "S = int(input())\ndp = [0] * (S + 1)\ndp[0] = 1\nM = 10**9 + 7\nfor i in range(1, S + 1):\n num = 0\n for j in range(i - 2):\n num += dp[j]\n dp[i] = num % M\nprint((dp[S]))\n", "code_v1_no_empty_lines": "S = int(input())\n\n\ndef cmb(n, r, p):\n r = min(n - r, r)\n if r == 0:\n return 1\n over = 1\n for i in range(n, n - r, -1):\n over = over * i % p\n under = 1\n for i in range(1, r + 1):\n under = under * i % p\n inv = pow(under, p - 2, p)\n return over * inv % p\n\n\nM = 10**9 + 7\nans = 0\nfor i in range(1, S):\n if S - 3 * i < 0:\n break\n ans += cmb(S - 3 * i + i - 1, i - 1, M)\n ans %= M\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 44.0, "diff": ["-dp = [0] * (S + 1)", "-dp[0] = 1", "+", "+", "+def cmb(n, r, p):", "+ r = min(n - r, r)", "+ if r == 0:", "+ return 1", "+ over = 1", "+ for i in range(n, n - r, -1):", "+ over = over * i % p", "+ under = 1", "+ for i in range(1, r + 1):", "+ under = under * i % p", "+ inv = pow(under, p - 2, p)", "+ return over * inv % p", "+", "+", "-for i in range(1, S + 1):", "- num = 0", "- for j in range(i - 2):", "- num += dp[j]", "- dp[i] = num % M", "-print((dp[S]))", "+ans = 0", "+for i in range(1, S):", "+ if S - 3 * i < 0:", "+ break", "+ ans += cmb(S - 3 * i + i - 1, i - 1, M)", "+ ans %= M", "+print(ans)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.6707954504, "measured_runtime_v1": 0.2514740815, "runtime_lift": 2.6674536254, "key": ["s422627112", "s801844924"]} {"user_id": "u326609687", "problem_id": "p03074", "language": "python", "submission_id_v0": "s171288721", "submission_id_v1": "s319292568", "cpu_time_v0": 80, "cpu_time_v1": 65, "memory_v0": 3316, "memory_v1": 4460, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 18.75, "input": "import sys\n\n\n\nN, K = list(map(int, input().split()))\n\nS = input()\n\n\n\n\n\ndef nexti(n):\n\n while S[n] == '1':\n\n n += 1\n\n while S[n] == '0':\n\n n += 1\n\n return n\n\n\n\n\n\ndef nextj(n):\n\n while S[n] == '0':\n\n n += 1\n\n if n == N:\n\n return N\n\n while S[n] == '1':\n\n n += 1\n\n if n == N:\n\n return N\n\n return n\n\n\n\n\n\ni = 0\n\nj = 0\n\nwhile S[j] == '1':\n\n j += 1\n\n if j == N:\n\n print(N)\n\n sys.exit(0)\n\nfor _ in range(K):\n\n j = nextj(j)\n\n if j == N:\n\n print(N)\n\n sys.exit(0)\n\n\n\nans = j - i\n\nwhile True:\n\n i = nexti(i)\n\n j = nextj(j)\n\n ans = max(ans, j - i)\n\n if j == N:\n\n break\n\n\n\nprint(ans)", "target": "from collections import deque\n\n\n\n\n\ndef nextj(n):\n\n while S[n] == '0':\n\n n += 1\n\n if n == N:\n\n return N\n\n q.appendleft(n)\n\n while S[n] == '1':\n\n n += 1\n\n if n == N:\n\n return N\n\n return n\n\n\n\n\n\ndef init(n):\n\n while S[n] == '1':\n\n n += 1\n\n if n == N:\n\n return N\n\n return n\n\n\n\n\n\ndef calc():\n\n q.appendleft(0)\n\n ans = 0\n\n j = init(0)\n\n if j == N:\n\n return N\n\n for _ in range(K - 1):\n\n j = nextj(j)\n\n if j == N:\n\n return N\n\n while True:\n\n j = nextj(j)\n\n ans = max(ans, j - q.pop())\n\n if j == N:\n\n return ans\n\n\n\n\n\nN, K = list(map(int, input().split()))\n\nS = input()\n\nq = deque()\n\nprint((calc()))\n", "code_v0_loc": 48, "code_v1_loc": 45, "code_v0_num_chars": 703, "code_v1_num_chars": 755, "code_v0_no_empty_lines": "import sys\n\nN, K = list(map(int, input().split()))\nS = input()\n\n\ndef nexti(n):\n while S[n] == \"1\":\n n += 1\n while S[n] == \"0\":\n n += 1\n return n\n\n\ndef nextj(n):\n while S[n] == \"0\":\n n += 1\n if n == N:\n return N\n while S[n] == \"1\":\n n += 1\n if n == N:\n return N\n return n\n\n\ni = 0\nj = 0\nwhile S[j] == \"1\":\n j += 1\n if j == N:\n print(N)\n sys.exit(0)\nfor _ in range(K):\n j = nextj(j)\n if j == N:\n print(N)\n sys.exit(0)\nans = j - i\nwhile True:\n i = nexti(i)\n j = nextj(j)\n ans = max(ans, j - i)\n if j == N:\n break\nprint(ans)\n", "code_v1_no_empty_lines": "from collections import deque\n\n\ndef nextj(n):\n while S[n] == \"0\":\n n += 1\n if n == N:\n return N\n q.appendleft(n)\n while S[n] == \"1\":\n n += 1\n if n == N:\n return N\n return n\n\n\ndef init(n):\n while S[n] == \"1\":\n n += 1\n if n == N:\n return N\n return n\n\n\ndef calc():\n q.appendleft(0)\n ans = 0\n j = init(0)\n if j == N:\n return N\n for _ in range(K - 1):\n j = nextj(j)\n if j == N:\n return N\n while True:\n j = nextj(j)\n ans = max(ans, j - q.pop())\n if j == N:\n return ans\n\n\nN, K = list(map(int, input().split()))\nS = input()\nq = deque()\nprint((calc()))\n", "code_same": false, "relative_loc_diff_percent": 6.25, "diff": ["-import sys", "-", "-N, K = list(map(int, input().split()))", "-S = input()", "-", "-", "-def nexti(n):", "- while S[n] == \"1\":", "- n += 1", "- while S[n] == \"0\":", "- n += 1", "- return n", "+from collections import deque", "+ q.appendleft(n)", "-i = 0", "-j = 0", "-while S[j] == \"1\":", "- j += 1", "+def init(n):", "+ while S[n] == \"1\":", "+ n += 1", "+ if n == N:", "+ return N", "+ return n", "+", "+", "+def calc():", "+ q.appendleft(0)", "+ ans = 0", "+ j = init(0)", "- print(N)", "- sys.exit(0)", "-for _ in range(K):", "- j = nextj(j)", "- if j == N:", "- print(N)", "- sys.exit(0)", "-ans = j - i", "-while True:", "- i = nexti(i)", "- j = nextj(j)", "- ans = max(ans, j - i)", "- if j == N:", "- break", "-print(ans)", "+ return N", "+ for _ in range(K - 1):", "+ j = nextj(j)", "+ if j == N:", "+ return N", "+ while True:", "+ j = nextj(j)", "+ ans = max(ans, j - q.pop())", "+ if j == N:", "+ return ans", "+", "+", "+N, K = list(map(int, input().split()))", "+S = input()", "+q = deque()", "+print((calc()))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3886394203, "measured_runtime_v1": 0.2086165268, "runtime_lift": 1.8629368734, "key": ["s171288721", "s319292568"]} {"user_id": "u197300260", "problem_id": "p03814", "language": "python", "submission_id_v0": "s932284243", "submission_id_v1": "s708109984", "cpu_time_v0": 36, "cpu_time_v1": 29, "memory_v0": 4012, "memory_v1": 3516, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 19.44, "input": "# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b\n\n# Python 1st Try\n\nimport copy\n\n\n\n\n\nclass Problem:\n\n def __init__(self, stringdata):\n\n self.stringdata = stringdata\n\n\n\n def solver(self):\n\n strcont = copy.copy(self.stringdata)\n\n result = 0\n\n rightposition = 0\n\n leftposition = len(strcont)\n\n j = 0\n\n while True:\n\n if strcont[j] == 'A':\n\n rightposition = j\n\n break\n\n else:\n\n j = j + 1\n\n j = leftposition - 1\n\n while True:\n\n if strcont[j] == 'Z':\n\n leftposition = j\n\n break\n\n else:\n\n j = j - 1\n\n\n\n result = leftposition - rightposition + 1\n\n return result\n\n\n\n\n\nif __name__ == \"__main__\":\n\n s = input()\n\n print((\"{}\".format(Problem(s).solver())))\n", "target": "# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b\n\n# Python 2nd Try\n\n\n\n\n\ndef solver(string):\n\n result = 200000\n\n aposi = 0\n\n zposi = len(string)\n\n for j in range(0, len(string), 1):\n\n if string[j] == 'A':\n\n aposi = j\n\n break\n\n for j in range(len(string)-1, -1, -1):\n\n if string[j] == 'Z':\n\n zposi = j\n\n break\n\n result = zposi - aposi + 1\n\n return result\n\n\n\n\n\nif __name__ == \"__main__\":\n\n s = input()\n\n print(('{}'.format(solver(s))))\n", "code_v0_loc": 36, "code_v1_loc": 23, "code_v0_num_chars": 875, "code_v1_num_chars": 527, "code_v0_no_empty_lines": "# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b\n# Python 1st Try\nimport copy\n\n\nclass Problem:\n def __init__(self, stringdata):\n self.stringdata = stringdata\n\n def solver(self):\n strcont = copy.copy(self.stringdata)\n result = 0\n rightposition = 0\n leftposition = len(strcont)\n j = 0\n while True:\n if strcont[j] == \"A\":\n rightposition = j\n break\n else:\n j = j + 1\n j = leftposition - 1\n while True:\n if strcont[j] == \"Z\":\n leftposition = j\n break\n else:\n j = j - 1\n result = leftposition - rightposition + 1\n return result\n\n\nif __name__ == \"__main__\":\n s = input()\n print((\"{}\".format(Problem(s).solver())))\n", "code_v1_no_empty_lines": "# Problem https://atcoder.jp/contests/abc053/tasks/abc053_b\n# Python 2nd Try\ndef solver(string):\n result = 200000\n aposi = 0\n zposi = len(string)\n for j in range(0, len(string), 1):\n if string[j] == \"A\":\n aposi = j\n break\n for j in range(len(string) - 1, -1, -1):\n if string[j] == \"Z\":\n zposi = j\n break\n result = zposi - aposi + 1\n return result\n\n\nif __name__ == \"__main__\":\n s = input()\n print((\"{}\".format(solver(s))))\n", "code_same": false, "relative_loc_diff_percent": 36.1111111111, "diff": ["-# Python 1st Try", "-import copy", "-", "-", "-class Problem:", "- def __init__(self, stringdata):", "- self.stringdata = stringdata", "-", "- def solver(self):", "- strcont = copy.copy(self.stringdata)", "- result = 0", "- rightposition = 0", "- leftposition = len(strcont)", "- j = 0", "- while True:", "- if strcont[j] == \"A\":", "- rightposition = j", "- break", "- else:", "- j = j + 1", "- j = leftposition - 1", "- while True:", "- if strcont[j] == \"Z\":", "- leftposition = j", "- break", "- else:", "- j = j - 1", "- result = leftposition - rightposition + 1", "- return result", "+# Python 2nd Try", "+def solver(string):", "+ result = 200000", "+ aposi = 0", "+ zposi = len(string)", "+ for j in range(0, len(string), 1):", "+ if string[j] == \"A\":", "+ aposi = j", "+ break", "+ for j in range(len(string) - 1, -1, -1):", "+ if string[j] == \"Z\":", "+ zposi = j", "+ break", "+ result = zposi - aposi + 1", "+ return result", "- print((\"{}\".format(Problem(s).solver())))", "+ print((\"{}\".format(solver(s))))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2169195101, "measured_runtime_v1": 0.1208960545, "runtime_lift": 1.7942645936, "key": ["s932284243", "s708109984"]} {"user_id": "u617515020", "problem_id": "p02814", "language": "python", "submission_id_v0": "s956521329", "submission_id_v1": "s164820491", "cpu_time_v0": 67, "cpu_time_v1": 51, "memory_v0": 16316, "memory_v1": 20372, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 23.88, "input": "from math import gcd\n\n\n\nn,m=list(map(int,input().split()))\n\na=list(map(int,input().split()))\n\na=list(set(a))\n\n\n\na=list([x//2 for x in a])\n\n\n\ndef lcm(q):\n\n x = q[0]\n\n for i in range(1, len(q)):\n\n x = (x * q[i]) // gcd(x, q[i])\n\n return x\n\n\n\nlcma=lcm(a)\n\n\n\nif (lcma//a[0])%2==0:\n\n print((0))\n\nelse:\n\n flg=0\n\n for i in range(1,len(a)):\n\n if (lcma//a[i])%2==0:\n\n print((0))\n\n flg=1\n\n break\n\n if flg==0:\n\n temp=m//lcma\n\n print((temp//2 if temp%2==0 else temp//2+1))", "target": "from math import gcd\n\nn,m=list(map(int,input().split()))\n\na=list(map(int,input().split()))\n\na=list(set(a))\n\na=list([x//2 for x in a])\n\n\n\ndef lcm(q):\n\n x = q[0]\n\n for i in range(1, len(q)):\n\n x = (x * q[i]) // gcd(x, q[i])\n\n return x\n\n\n\nlcma=lcm(a)\n\nfor i in range(len(a)):\n\n if (lcma//a[i])%2==0:\n\n print((0))\n\n exit()\n\ntemp=m//lcma\n\nprint((temp//2 if temp%2==0 else temp//2+1))", "code_v0_loc": 28, "code_v1_loc": 19, "code_v0_num_chars": 492, "code_v1_num_chars": 386, "code_v0_no_empty_lines": "from math import gcd\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\na = list(set(a))\na = list([x // 2 for x in a])\n\n\ndef lcm(q):\n x = q[0]\n for i in range(1, len(q)):\n x = (x * q[i]) // gcd(x, q[i])\n return x\n\n\nlcma = lcm(a)\nif (lcma // a[0]) % 2 == 0:\n print((0))\nelse:\n flg = 0\n for i in range(1, len(a)):\n if (lcma // a[i]) % 2 == 0:\n print((0))\n flg = 1\n break\n if flg == 0:\n temp = m // lcma\n print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))\n", "code_v1_no_empty_lines": "from math import gcd\n\nn, m = list(map(int, input().split()))\na = list(map(int, input().split()))\na = list(set(a))\na = list([x // 2 for x in a])\n\n\ndef lcm(q):\n x = q[0]\n for i in range(1, len(q)):\n x = (x * q[i]) // gcd(x, q[i])\n return x\n\n\nlcma = lcm(a)\nfor i in range(len(a)):\n if (lcma // a[i]) % 2 == 0:\n print((0))\n exit()\ntemp = m // lcma\nprint((temp // 2 if temp % 2 == 0 else temp // 2 + 1))\n", "code_same": false, "relative_loc_diff_percent": 32.1428571429, "diff": ["-from math import gcd", "+from math import gcd", "-if (lcma // a[0]) % 2 == 0:", "- print((0))", "-else:", "- flg = 0", "- for i in range(1, len(a)):", "- if (lcma // a[i]) % 2 == 0:", "- print((0))", "- flg = 1", "- break", "- if flg == 0:", "- temp = m // lcma", "- print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))", "+for i in range(len(a)):", "+ if (lcma // a[i]) % 2 == 0:", "+ print((0))", "+ exit()", "+temp = m // lcma", "+print((temp // 2 if temp % 2 == 0 else temp // 2 + 1))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2803374403, "measured_runtime_v1": 0.2137892873, "runtime_lift": 1.3112791747, "key": ["s956521329", "s164820491"]} {"user_id": "u038021590", "problem_id": "p03171", "language": "python", "submission_id_v0": "s330952971", "submission_id_v1": "s165498833", "cpu_time_v0": 615, "cpu_time_v1": 234, "memory_v0": 115036, "memory_v1": 135316, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 61.95, "input": "N = int(input())\n\nA = list(map(int, input().split()))\n\nn = N % 2\n\n\n\nDP = [[0] * (N+1) for _ in range(N+1)]\n\n\n\nfor w in range(1, N+1):\n\n for i in range(N):\n\n j = i + w\n\n if j > N:\n\n continue\n\n if (w+n) % 2 == 1:\n\n DP[i][j] = min(DP[i+1][j] - A[i], DP[i][j-1] - A[j-1])\n\n else:\n\n DP[i][j] = max(DP[i+1][j] + A[i], DP[i][j-1] + A[j-1])\n\n\n\nprint((DP[0][N]))\n", "target": "N = int(input())\n\nA = list(map(int, input().split()))\n\nDP = [[0] * (N+1) for _ in range(N+1)]\n\n\n\nfor num in range(1, N + 1):\n\n for start in range(N):\n\n end = start + num\n\n if end > N:\n\n break\n\n if num == 1:\n\n DP[start][end] = A[start]\n\n else:\n\n DP[start][end] = max(A[start] - DP[start+1][end], A[end - 1] - DP[start][end - 1])\n\nprint((DP[0][N]))\n", "code_v0_loc": 17, "code_v1_loc": 14, "code_v0_num_chars": 416, "code_v1_num_chars": 409, "code_v0_no_empty_lines": "N = int(input())\nA = list(map(int, input().split()))\nn = N % 2\nDP = [[0] * (N + 1) for _ in range(N + 1)]\nfor w in range(1, N + 1):\n for i in range(N):\n j = i + w\n if j > N:\n continue\n if (w + n) % 2 == 1:\n DP[i][j] = min(DP[i + 1][j] - A[i], DP[i][j - 1] - A[j - 1])\n else:\n DP[i][j] = max(DP[i + 1][j] + A[i], DP[i][j - 1] + A[j - 1])\nprint((DP[0][N]))\n", "code_v1_no_empty_lines": "N = int(input())\nA = list(map(int, input().split()))\nDP = [[0] * (N + 1) for _ in range(N + 1)]\nfor num in range(1, N + 1):\n for start in range(N):\n end = start + num\n if end > N:\n break\n if num == 1:\n DP[start][end] = A[start]\n else:\n DP[start][end] = max(\n A[start] - DP[start + 1][end], A[end - 1] - DP[start][end - 1]\n )\nprint((DP[0][N]))\n", "code_same": false, "relative_loc_diff_percent": 17.6470588235, "diff": ["-n = N % 2", "-for w in range(1, N + 1):", "- for i in range(N):", "- j = i + w", "- if j > N:", "- continue", "- if (w + n) % 2 == 1:", "- DP[i][j] = min(DP[i + 1][j] - A[i], DP[i][j - 1] - A[j - 1])", "+for num in range(1, N + 1):", "+ for start in range(N):", "+ end = start + num", "+ if end > N:", "+ break", "+ if num == 1:", "+ DP[start][end] = A[start]", "- DP[i][j] = max(DP[i + 1][j] + A[i], DP[i][j - 1] + A[j - 1])", "+ DP[start][end] = max(", "+ A[start] - DP[start + 1][end], A[end - 1] - DP[start][end - 1]", "+ )"], "diff_only_import_comment": false, "measured_runtime_v0": 0.1878290408, "measured_runtime_v1": 0.0068282696, "runtime_lift": 27.5075605354, "key": ["s330952971", "s165498833"]} {"user_id": "u957843607", "problem_id": "p02574", "language": "python", "submission_id_v0": "s835620267", "submission_id_v1": "s021486096", "cpu_time_v0": 703, "cpu_time_v1": 584, "memory_v0": 134500, "memory_v1": 134400, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 16.93, "input": "from math import gcd\n\n\n\nN = int(input())\n\nnum_lis = list(map(int, input().split()))\n\nc = True\n\n\n\ndef osa_k(max_num):\n\n lis = [i for i in range(max_num+1)]\n\n p = 2\n\n while p**2 <= max_num:\n\n if lis[p] == p:\n\n for q in range(2*p, max_num+1, p):\n\n if lis[q] == q:\n\n lis[q] = p\n\n p += 1\n\n return lis\n\n\n\nhoge = 0\n\nfor i in num_lis:\n\n hoge = gcd(hoge, i)\n\nif hoge > 1:\n\n print(\"not coprime\")\n\n exit()\n\n\n\nd_lis = osa_k(10**6+10)\n\ntmp = set()\n\nfor i in num_lis:\n\n num = i\n\n new_tmp = set()\n\n while num > 1:\n\n d = d_lis[num]\n\n new_tmp.add(d)\n\n num //= d\n\n for j in new_tmp:\n\n if j in tmp:\n\n c = False\n\n break\n\n else:\n\n tmp.add(j)\n\n else:\n\n continue\n\n break\n\n\n\nif c:\n\n print(\"pairwise coprime\")\n\nelse:\n\n print(\"setwise coprime\")", "target": "from math import gcd\n\n\n\nN = int(input())\n\nnum_lis = list(map(int, input().split()))\n\n\n\ndef osa_k(max_num):\n\n lis = [i for i in range(max_num+1)]\n\n p = 2\n\n while p**2 <= max_num:\n\n if lis[p] == p:\n\n for q in range(2*p, max_num+1, p):\n\n if lis[q] == q:\n\n lis[q] = p\n\n p += 1\n\n return lis\n\n\n\nhoge = 0\n\nfor i in num_lis:\n\n hoge = gcd(hoge, i)\n\nif hoge > 1:\n\n print(\"not coprime\")\n\n exit()\n\n\n\nd_lis = osa_k(max(num_lis))\n\ntmp = set()\n\nfor i in num_lis:\n\n num = i\n\n new_tmp = set()\n\n while num > 1:\n\n d = d_lis[num]\n\n new_tmp.add(d)\n\n num //= d\n\n for j in new_tmp:\n\n if j in tmp:\n\n print(\"setwise coprime\")\n\n exit()\n\n else:\n\n tmp.add(j)\n\nprint(\"pairwise coprime\")", "code_v0_loc": 47, "code_v1_loc": 39, "code_v0_num_chars": 793, "code_v1_num_chars": 725, "code_v0_no_empty_lines": "from math import gcd\n\nN = int(input())\nnum_lis = list(map(int, input().split()))\nc = True\n\n\ndef osa_k(max_num):\n lis = [i for i in range(max_num + 1)]\n p = 2\n while p**2 <= max_num:\n if lis[p] == p:\n for q in range(2 * p, max_num + 1, p):\n if lis[q] == q:\n lis[q] = p\n p += 1\n return lis\n\n\nhoge = 0\nfor i in num_lis:\n hoge = gcd(hoge, i)\nif hoge > 1:\n print(\"not coprime\")\n exit()\nd_lis = osa_k(10**6 + 10)\ntmp = set()\nfor i in num_lis:\n num = i\n new_tmp = set()\n while num > 1:\n d = d_lis[num]\n new_tmp.add(d)\n num //= d\n for j in new_tmp:\n if j in tmp:\n c = False\n break\n else:\n tmp.add(j)\n else:\n continue\n break\nif c:\n print(\"pairwise coprime\")\nelse:\n print(\"setwise coprime\")\n", "code_v1_no_empty_lines": "from math import gcd\n\nN = int(input())\nnum_lis = list(map(int, input().split()))\n\n\ndef osa_k(max_num):\n lis = [i for i in range(max_num + 1)]\n p = 2\n while p**2 <= max_num:\n if lis[p] == p:\n for q in range(2 * p, max_num + 1, p):\n if lis[q] == q:\n lis[q] = p\n p += 1\n return lis\n\n\nhoge = 0\nfor i in num_lis:\n hoge = gcd(hoge, i)\nif hoge > 1:\n print(\"not coprime\")\n exit()\nd_lis = osa_k(max(num_lis))\ntmp = set()\nfor i in num_lis:\n num = i\n new_tmp = set()\n while num > 1:\n d = d_lis[num]\n new_tmp.add(d)\n num //= d\n for j in new_tmp:\n if j in tmp:\n print(\"setwise coprime\")\n exit()\n else:\n tmp.add(j)\nprint(\"pairwise coprime\")\n", "code_same": false, "relative_loc_diff_percent": 17.0212765957, "diff": ["-c = True", "-d_lis = osa_k(10**6 + 10)", "+d_lis = osa_k(max(num_lis))", "- c = False", "- break", "+ print(\"setwise coprime\")", "+ exit()", "- else:", "- continue", "- break", "-if c:", "- print(\"pairwise coprime\")", "-else:", "- print(\"setwise coprime\")", "+print(\"pairwise coprime\")"], "diff_only_import_comment": false, "measured_runtime_v0": 2.272307416, "measured_runtime_v1": 0.2046107306, "runtime_lift": 11.1055144012, "key": ["s835620267", "s021486096"]} {"user_id": "u380524497", "problem_id": "p02850", "language": "python", "submission_id_v0": "s943818401", "submission_id_v1": "s978957689", "cpu_time_v0": 583, "cpu_time_v1": 446, "memory_v0": 25092, "memory_v1": 25184, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 23.5, "input": "n = int(input())\n\nedges = []\n\n\n\nfor id in range(n-1):\n\n a, b = list(map(int, input().split()))\n\n edges.append([a-1, b-1, id])\n\n\n\nedges.sort()\n\n\n\nused = [0]*(n)\n\nans = [0]*(n-1)\n\nnum = 1\n\nprev = 0\n\nfor edge in edges:\n\n _from, to, id = edge\n\n if _from != prev:\n\n num = 1\n\n if used[_from] == num:\n\n num += 1\n\n ans[id] = num\n\n used[to] = num\n\n num += 1\n\n prev = _from\n\n\n\nprint((max(ans)))\n\nfor color in ans:\n\n print(color)\n", "target": "import sys\n\ninput = sys.stdin.readline\n\n\n\nn = int(input())\n\nedges = []\n\n\n\nfor id in range(n-1):\n\n a, b = list(map(int, input().split()))\n\n edges.append([a-1, b-1, id])\n\n\n\nedges.sort()\n\n\n\nused = [0]*(n)\n\nans = [0]*(n-1)\n\nnum = 1\n\nprev = 0\n\nfor edge in edges:\n\n _from, to, id = edge\n\n if _from != prev:\n\n num = 1\n\n if used[_from] == num:\n\n num += 1\n\n ans[id] = num\n\n used[to] = num\n\n num += 1\n\n prev = _from\n\n\n\nprint((max(ans)))\n\nfor color in ans:\n\n print(color)\n", "code_v0_loc": 27, "code_v1_loc": 30, "code_v0_num_chars": 455, "code_v1_num_chars": 497, "code_v0_no_empty_lines": "n = int(input())\nedges = []\nfor id in range(n - 1):\n a, b = list(map(int, input().split()))\n edges.append([a - 1, b - 1, id])\nedges.sort()\nused = [0] * (n)\nans = [0] * (n - 1)\nnum = 1\nprev = 0\nfor edge in edges:\n _from, to, id = edge\n if _from != prev:\n num = 1\n if used[_from] == num:\n num += 1\n ans[id] = num\n used[to] = num\n num += 1\n prev = _from\nprint((max(ans)))\nfor color in ans:\n print(color)\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nn = int(input())\nedges = []\nfor id in range(n - 1):\n a, b = list(map(int, input().split()))\n edges.append([a - 1, b - 1, id])\nedges.sort()\nused = [0] * (n)\nans = [0] * (n - 1)\nnum = 1\nprev = 0\nfor edge in edges:\n _from, to, id = edge\n if _from != prev:\n num = 1\n if used[_from] == num:\n num += 1\n ans[id] = num\n used[to] = num\n num += 1\n prev = _from\nprint((max(ans)))\nfor color in ans:\n print(color)\n", "code_same": false, "relative_loc_diff_percent": 10.0, "diff": ["+import sys", "+", "+input = sys.stdin.readline"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2558188839, "measured_runtime_v1": 0.0060829046, "runtime_lift": 42.0553832838, "key": ["s943818401", "s978957689"]} {"user_id": "u633068244", "problem_id": "p00122", "language": "python", "submission_id_v0": "s871701752", "submission_id_v1": "s889694954", "cpu_time_v0": 20, "cpu_time_v1": 10, "memory_v0": 4272, "memory_v1": 4268, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 50.0, "input": "dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]\n\ndY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]\n\ndef solve(x,y,XY):\n\n\txy = XY[:]\n\n\tif len(xy) == 0: return \"OK\"\n\n\tsx,sy = xy.pop(0),xy.pop(0)\n\n\tfor dx,dy in zip(dX,dY):\n\n\t\tif doa(x+dx,y+dy,sx,sy): \n\n\t\t\tr = solve(x+dx,y+dy,xy)\n\n\t\t\tif r: return r\n\n\n\ndef doa(x,y,sx,sy):\n\n\tif not (0 <= x <= 9 and 0 <= y <= 9): return False\n\n\treturn True if abs(x-sx) < 2 and abs(y-sy) < 2 else False\n\n\n\nwhile 1:\n\n\tx,y = list(map(int,input().split()))\n\n\tif x == y == 0: break\n\n\tn = input()\n\n\txy = list(map(int,input().split()))\n\n\tans = solve(x,y,xy)\n\n\tprint(ans if ans else \"NA\")", "target": "dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]\n\ndY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]\n\ndef solve(x,y,XY):\n\n\txy = XY[:]\n\n\tif len(xy) == 0: return True\n\n\tsx,sy = xy.pop(0),xy.pop(0)\n\n\tfor dx,dy in zip(dX,dY):\n\n\t\tif doa(x+dx,y+dy,sx,sy): \n\n\t\t\tr = solve(x+dx,y+dy,xy)\n\n\t\t\tif r: return r\n\n\n\ndef doa(x,y,sx,sy):\n\n\tif not (0 <= x <= 9 and 0 <= y <= 9): return False\n\n\treturn True if abs(x-sx) < 2 and abs(y-sy) < 2 else False\n\n\n\nwhile 1:\n\n\tx,y = list(map(int,input().split()))\n\n\tif x == y == 0: break\n\n\tn = input()\n\n\txy = list(map(int,input().split()))\n\n\tprint(\"OK\" if solve(x,y,xy) else \"NA\")", "code_v0_loc": 22, "code_v1_loc": 21, "code_v0_num_chars": 579, "code_v1_num_chars": 568, "code_v0_no_empty_lines": "dX = [2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1]\ndY = [-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2]\n\n\ndef solve(x, y, XY):\n xy = XY[:]\n if len(xy) == 0:\n return \"OK\"\n sx, sy = xy.pop(0), xy.pop(0)\n for dx, dy in zip(dX, dY):\n if doa(x + dx, y + dy, sx, sy):\n r = solve(x + dx, y + dy, xy)\n if r:\n return r\n\n\ndef doa(x, y, sx, sy):\n if not (0 <= x <= 9 and 0 <= y <= 9):\n return False\n return True if abs(x - sx) < 2 and abs(y - sy) < 2 else False\n\n\nwhile 1:\n x, y = list(map(int, input().split()))\n if x == y == 0:\n break\n n = input()\n xy = list(map(int, input().split()))\n ans = solve(x, y, xy)\n print(ans if ans else \"NA\")\n", "code_v1_no_empty_lines": "dX = [2, 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1]\ndY = [-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2]\n\n\ndef solve(x, y, XY):\n xy = XY[:]\n if len(xy) == 0:\n return True\n sx, sy = xy.pop(0), xy.pop(0)\n for dx, dy in zip(dX, dY):\n if doa(x + dx, y + dy, sx, sy):\n r = solve(x + dx, y + dy, xy)\n if r:\n return r\n\n\ndef doa(x, y, sx, sy):\n if not (0 <= x <= 9 and 0 <= y <= 9):\n return False\n return True if abs(x - sx) < 2 and abs(y - sy) < 2 else False\n\n\nwhile 1:\n x, y = list(map(int, input().split()))\n if x == y == 0:\n break\n n = input()\n xy = list(map(int, input().split()))\n print(\"OK\" if solve(x, y, xy) else \"NA\")\n", "code_same": false, "relative_loc_diff_percent": 4.5454545455, "diff": ["- return \"OK\"", "+ return True", "- ans = solve(x, y, xy)", "- print(ans if ans else \"NA\")", "+ print(\"OK\" if solve(x, y, xy) else \"NA\")"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2335389843, "measured_runtime_v1": 0.183096947, "runtime_lift": 1.2754936015, "key": ["s871701752", "s889694954"]} {"user_id": "u670180528", "problem_id": "p03634", "language": "python", "submission_id_v0": "s592706363", "submission_id_v1": "s081294326", "cpu_time_v0": 718, "cpu_time_v1": 476, "memory_v0": 63540, "memory_v1": 64180, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 33.7, "input": "from collections import deque\n\nn,*t=list(map(int,open(0).read().split()))\n\ncon=[[] for _ in range(n)]\n\ndist_f_k=[0]*n\n\n\n\nfor a,b,c in zip(t[:3*n-3:3],t[1::3],t[2::3]):\n\n\tcon[a-1].append((b-1,c))\n\n\tcon[b-1].append((a-1,c))\n\n\n\nk=t[3*n-2]\n\nque=deque([k-1])\n\nwhile que:\n\n\tcur=que.popleft()\n\n\tfor nxt,dd in con[cur]:\n\n\t\tif dist_f_k[nxt]==0 and nxt!=k-1:\n\n\t\t\tque.append(nxt)\n\n\t\t\tdist_f_k[nxt]=dist_f_k[cur]+dd\n\n\n\nfor x,y in zip(t[3*n-1::2],t[3*n::2]):\n\n\tprint((dist_f_k[x-1]+dist_f_k[y-1]))", "target": "def solve():\n\n\tfrom collections import deque\n\n\tn,*t=list(map(int,open(0).read().split()))\n\n\tcon=[[] for _ in range(n)]\n\n\tdist_f_k=[0]*n\n\n\tl1,l2=t[:3*n-3],t[3*n-1:]\n\n\n\n\tfor a,b,c in zip(*[iter(l1)]*3):\n\n\t\tcon[a-1].append((b-1,c))\n\n\t\tcon[b-1].append((a-1,c))\n\n\n\n\tk=t[3*n-2]\n\n\tque=deque([k-1])\n\n\twhile que:\n\n\t\tcur=que.popleft()\n\n\t\tfor nxt,dd in con[cur]:\n\n\t\t\tif dist_f_k[nxt]==0 and nxt!=k-1:\n\n\t\t\t\tque.append(nxt)\n\n\t\t\t\tdist_f_k[nxt]=dist_f_k[cur]+dd\n\n\n\n\tfor x,y in zip(*[iter(l2)]*2):\n\n\t\tprint((dist_f_k[x-1]+dist_f_k[y-1]))\n\n\t\t\n\nif __name__==\"__main__\":\n\n\tsolve()", "code_v0_loc": 20, "code_v1_loc": 25, "code_v0_num_chars": 476, "code_v1_num_chars": 553, "code_v0_no_empty_lines": "from collections import deque\n\nn, *t = list(map(int, open(0).read().split()))\ncon = [[] for _ in range(n)]\ndist_f_k = [0] * n\nfor a, b, c in zip(t[: 3 * n - 3 : 3], t[1::3], t[2::3]):\n con[a - 1].append((b - 1, c))\n con[b - 1].append((a - 1, c))\nk = t[3 * n - 2]\nque = deque([k - 1])\nwhile que:\n cur = que.popleft()\n for nxt, dd in con[cur]:\n if dist_f_k[nxt] == 0 and nxt != k - 1:\n que.append(nxt)\n dist_f_k[nxt] = dist_f_k[cur] + dd\nfor x, y in zip(t[3 * n - 1 :: 2], t[3 * n :: 2]):\n print((dist_f_k[x - 1] + dist_f_k[y - 1]))\n", "code_v1_no_empty_lines": "def solve():\n from collections import deque\n\n n, *t = list(map(int, open(0).read().split()))\n con = [[] for _ in range(n)]\n dist_f_k = [0] * n\n l1, l2 = t[: 3 * n - 3], t[3 * n - 1 :]\n for a, b, c in zip(*[iter(l1)] * 3):\n con[a - 1].append((b - 1, c))\n con[b - 1].append((a - 1, c))\n k = t[3 * n - 2]\n que = deque([k - 1])\n while que:\n cur = que.popleft()\n for nxt, dd in con[cur]:\n if dist_f_k[nxt] == 0 and nxt != k - 1:\n que.append(nxt)\n dist_f_k[nxt] = dist_f_k[cur] + dd\n for x, y in zip(*[iter(l2)] * 2):\n print((dist_f_k[x - 1] + dist_f_k[y - 1]))\n\n\nif __name__ == \"__main__\":\n solve()\n", "code_same": false, "relative_loc_diff_percent": 20.0, "diff": ["-from collections import deque", "+def solve():", "+ from collections import deque", "-n, *t = list(map(int, open(0).read().split()))", "-con = [[] for _ in range(n)]", "-dist_f_k = [0] * n", "-for a, b, c in zip(t[: 3 * n - 3 : 3], t[1::3], t[2::3]):", "- con[a - 1].append((b - 1, c))", "- con[b - 1].append((a - 1, c))", "-k = t[3 * n - 2]", "-que = deque([k - 1])", "-while que:", "- cur = que.popleft()", "- for nxt, dd in con[cur]:", "- if dist_f_k[nxt] == 0 and nxt != k - 1:", "- que.append(nxt)", "- dist_f_k[nxt] = dist_f_k[cur] + dd", "-for x, y in zip(t[3 * n - 1 :: 2], t[3 * n :: 2]):", "- print((dist_f_k[x - 1] + dist_f_k[y - 1]))", "+ n, *t = list(map(int, open(0).read().split()))", "+ con = [[] for _ in range(n)]", "+ dist_f_k = [0] * n", "+ l1, l2 = t[: 3 * n - 3], t[3 * n - 1 :]", "+ for a, b, c in zip(*[iter(l1)] * 3):", "+ con[a - 1].append((b - 1, c))", "+ con[b - 1].append((a - 1, c))", "+ k = t[3 * n - 2]", "+ que = deque([k - 1])", "+ while que:", "+ cur = que.popleft()", "+ for nxt, dd in con[cur]:", "+ if dist_f_k[nxt] == 0 and nxt != k - 1:", "+ que.append(nxt)", "+ dist_f_k[nxt] = dist_f_k[cur] + dd", "+ for x, y in zip(*[iter(l2)] * 2):", "+ print((dist_f_k[x - 1] + dist_f_k[y - 1]))", "+", "+", "+if __name__ == \"__main__\":", "+ solve()"], "diff_only_import_comment": false, "measured_runtime_v0": 0.331901531, "measured_runtime_v1": 0.2149364519, "runtime_lift": 1.5441844695, "key": ["s592706363", "s081294326"]} {"user_id": "u604774382", "problem_id": "p02264", "language": "python", "submission_id_v0": "s685908626", "submission_id_v1": "s418135932", "cpu_time_v0": 1410, "cpu_time_v1": 1260, "memory_v0": 17580, "memory_v1": 11516, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 10.64, "input": "n, q = [ int( val ) for val in input( ).split( \" \" ) ]\n\nps = [0]*n\n\nt = [0]*n\n\nfor i in range( n ):\n\n\tps[i], t[i] = input( ).split( \" \" )\n\n\n\n\n\noutput = []\n\nqsum = 0\n\nwhile t:\n\n\tpsi = ps.pop( 0 )\n\n\tti = int( t.pop( 0 ) )\n\n\tif ti <= q:\n\n\t\tqsum += ti\t\n\n\t\toutput.append( psi+\" \"+str( qsum ) )\n\n\telse:\n\n\t\tt.append( ti - q )\n\n\t\tps.append( psi )\n\n\t\tqsum += q\n\n\n\nprint(( \"\\n\".join( output ) ))", "target": "n, q = [ int( val ) for val in input( ).split( \" \" ) ]\n\nps = [0]*n\n\nt = [0]*n\n\nfor i in range( n ):\n\n ps[i], t[i] = input( ).split( \" \" )\n\n \n\n \n\noutput = []\n\nqsum = 0\n\nwhile t:\n\n psi = ps.pop( 0 )\n\n ti = int( t.pop( 0 ) )\n\n if ti <= q:\n\n qsum += ti\n\n output.append( \"\".join( ( psi, \" \", str( qsum ) ) ) )\n\n else:\n\n t.append( ti - q )\n\n ps.append( psi )\n\n qsum += q\n\n \n\nprint(( \"\\n\".join( output ) ))", "code_v0_loc": 21, "code_v1_loc": 21, "code_v0_num_chars": 383, "code_v1_num_chars": 455, "code_v0_no_empty_lines": "n, q = [int(val) for val in input().split(\" \")]\nps = [0] * n\nt = [0] * n\nfor i in range(n):\n ps[i], t[i] = input().split(\" \")\noutput = []\nqsum = 0\nwhile t:\n psi = ps.pop(0)\n ti = int(t.pop(0))\n if ti <= q:\n qsum += ti\n output.append(psi + \" \" + str(qsum))\n else:\n t.append(ti - q)\n ps.append(psi)\n qsum += q\nprint((\"\\n\".join(output)))\n", "code_v1_no_empty_lines": "n, q = [int(val) for val in input().split(\" \")]\nps = [0] * n\nt = [0] * n\nfor i in range(n):\n ps[i], t[i] = input().split(\" \")\noutput = []\nqsum = 0\nwhile t:\n psi = ps.pop(0)\n ti = int(t.pop(0))\n if ti <= q:\n qsum += ti\n output.append(\"\".join((psi, \" \", str(qsum))))\n else:\n t.append(ti - q)\n ps.append(psi)\n qsum += q\nprint((\"\\n\".join(output)))\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- output.append(psi + \" \" + str(qsum))", "+ output.append(\"\".join((psi, \" \", str(qsum))))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2516228666, "measured_runtime_v1": 0.0710392208, "runtime_lift": 3.5420274002, "key": ["s685908626", "s418135932"]} {"user_id": "u806976856", "problem_id": "p02555", "language": "python", "submission_id_v0": "s550500681", "submission_id_v1": "s439989437", "cpu_time_v0": 123, "cpu_time_v1": 70, "memory_v0": 9160, "memory_v1": 64844, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 43.09, "input": "s=int(input())\n\np=10**9+7\n\nif s<=2:\n\n print((0))\n\n exit()\n\nn=s//3\n\nans=0\n\ndef f(n,k,p):\n\n if k==0:\n\n return 1\n\n elif k%2==0:\n\n return (f(n,k//2,p)**2)%p\n\n else:\n\n return (n*f(n,k-1,p))%p\n\n\n\nfor k in range(1,n+1):\n\n a=1\n\n b=1\n\n for j in range(k-1):\n\n a=(a*(s-3*k+1+j))%p\n\n b=(b*(j+1))%p\n\n ans=(ans+a*f(b,p-2,p))%p\n\n\n\nprint((ans%p))\n\n\n", "target": "s=int(input())\n\np=10**9+7\n\nif s<=2:\n\n print((0))\n\n exit()\n\nn=s//3\n\nans=0\n\nx=[0]*(s+1)\n\nx[0]=1\n\nx[1]=1\n\ny=[0]*(s+1)\n\n\n\nfor i in range(2,s+1):\n\n x[i]=x[i-1]*i%p\n\n\n\ny[s]=pow(x[s],p-2,p)\n\nfor i in range(s):\n\n y[s-1-i]=y[s-i]*(s-i)%p\n\n\n\nfor k in range(1,n+1):\n\n ans+=x[s-2*k-1]*y[k-1]*y[s-3*k]%p\n\n\n\nprint((ans%p))\n\n\n", "code_v0_loc": 25, "code_v1_loc": 24, "code_v0_num_chars": 391, "code_v1_num_chars": 322, "code_v0_no_empty_lines": "s = int(input())\np = 10**9 + 7\nif s <= 2:\n print((0))\n exit()\nn = s // 3\nans = 0\n\n\ndef f(n, k, p):\n if k == 0:\n return 1\n elif k % 2 == 0:\n return (f(n, k // 2, p) ** 2) % p\n else:\n return (n * f(n, k - 1, p)) % p\n\n\nfor k in range(1, n + 1):\n a = 1\n b = 1\n for j in range(k - 1):\n a = (a * (s - 3 * k + 1 + j)) % p\n b = (b * (j + 1)) % p\n ans = (ans + a * f(b, p - 2, p)) % p\nprint((ans % p))\n", "code_v1_no_empty_lines": "s = int(input())\np = 10**9 + 7\nif s <= 2:\n print((0))\n exit()\nn = s // 3\nans = 0\nx = [0] * (s + 1)\nx[0] = 1\nx[1] = 1\ny = [0] * (s + 1)\nfor i in range(2, s + 1):\n x[i] = x[i - 1] * i % p\ny[s] = pow(x[s], p - 2, p)\nfor i in range(s):\n y[s - 1 - i] = y[s - i] * (s - i) % p\nfor k in range(1, n + 1):\n ans += x[s - 2 * k - 1] * y[k - 1] * y[s - 3 * k] % p\nprint((ans % p))\n", "code_same": false, "relative_loc_diff_percent": 4.0, "diff": ["-", "-", "-def f(n, k, p):", "- if k == 0:", "- return 1", "- elif k % 2 == 0:", "- return (f(n, k // 2, p) ** 2) % p", "- else:", "- return (n * f(n, k - 1, p)) % p", "-", "-", "+x = [0] * (s + 1)", "+x[0] = 1", "+x[1] = 1", "+y = [0] * (s + 1)", "+for i in range(2, s + 1):", "+ x[i] = x[i - 1] * i % p", "+y[s] = pow(x[s], p - 2, p)", "+for i in range(s):", "+ y[s - 1 - i] = y[s - i] * (s - i) % p", "- a = 1", "- b = 1", "- for j in range(k - 1):", "- a = (a * (s - 3 * k + 1 + j)) % p", "- b = (b * (j + 1)) % p", "- ans = (ans + a * f(b, p - 2, p)) % p", "+ ans += x[s - 2 * k - 1] * y[k - 1] * y[s - 3 * k] % p"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3091425891, "measured_runtime_v1": 0.216736346, "runtime_lift": 1.4263532387, "key": ["s550500681", "s439989437"]} {"user_id": "u479719434", "problem_id": "p02665", "language": "python", "submission_id_v0": "s890279539", "submission_id_v1": "s923250526", "cpu_time_v0": 175, "cpu_time_v1": 149, "memory_v0": 26380, "memory_v1": 22304, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 14.86, "input": "n = int(input())\n\nleaves = list(map(int, input().split()))\n\n\n\nans = 0\n\nnodes_min = [0] * (n + 1)\n\nnodes_max = [0] * (n + 1)\n\nnodes_min[n] = leaves[n]\n\nnodes_max[n] = leaves[n]\n\n\n\nfor depth in range(n, 0, -1):\n\n root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2\n\n nodes_min[depth - 1] = leaves[depth - 1] + root_min\n\n root_max = nodes_max[depth]\n\n nodes_max[depth - 1] = leaves[depth - 1] + root_max\n\nnodes = [0] * (n + 1)\n\nnodes[0] = 1\n\nif nodes[0] < nodes_min[0]:\n\n print((-1))\n\nelse:\n\n for depth in range(n):\n\n roots = nodes[depth]-leaves[depth]\n\n nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])\n\n if nodes[depth+1] < nodes_min[depth+1]:\n\n print((-1))\n\n break\n\n else:\n\n print((sum(nodes)))\n", "target": "n = int(input())\n\nleaves = list(map(int, input().split()))\n\n\n\nsum_leaves = [0]*(n+1)\n\nsum_leaves[0] = leaves[0]\n\nfor depth in range(n):\n\n sum_leaves[depth+1] = sum_leaves[depth] + leaves[depth+1]\n\n\n\nans = 0\n\n\n\nroot = [None] * (n + 1)\n\nif n == 0:\n\n root[0] = 0\n\nelse:\n\n root[0] = 1\n\nif root[0] + leaves[0] != 1:\n\n print((-1))\n\nelse:\n\n for depth in range(n):\n\n root[depth+1] = min(2*root[depth]-leaves[depth+1],\n\n sum_leaves[n]-sum_leaves[depth+1])\n\n if root[depth + 1] < root[depth] - leaves[depth + 1] or root[depth+1] < 0:\n\n print((-1))\n\n break\n\n else:\n\n print((sum(root)+sum(leaves)))\n", "code_v0_loc": 27, "code_v1_loc": 26, "code_v0_num_chars": 771, "code_v1_num_chars": 669, "code_v0_no_empty_lines": "n = int(input())\nleaves = list(map(int, input().split()))\nans = 0\nnodes_min = [0] * (n + 1)\nnodes_max = [0] * (n + 1)\nnodes_min[n] = leaves[n]\nnodes_max[n] = leaves[n]\nfor depth in range(n, 0, -1):\n root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2\n nodes_min[depth - 1] = leaves[depth - 1] + root_min\n root_max = nodes_max[depth]\n nodes_max[depth - 1] = leaves[depth - 1] + root_max\nnodes = [0] * (n + 1)\nnodes[0] = 1\nif nodes[0] < nodes_min[0]:\n print((-1))\nelse:\n for depth in range(n):\n roots = nodes[depth] - leaves[depth]\n nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])\n if nodes[depth + 1] < nodes_min[depth + 1]:\n print((-1))\n break\n else:\n print((sum(nodes)))\n", "code_v1_no_empty_lines": "n = int(input())\nleaves = list(map(int, input().split()))\nsum_leaves = [0] * (n + 1)\nsum_leaves[0] = leaves[0]\nfor depth in range(n):\n sum_leaves[depth + 1] = sum_leaves[depth] + leaves[depth + 1]\nans = 0\nroot = [None] * (n + 1)\nif n == 0:\n root[0] = 0\nelse:\n root[0] = 1\nif root[0] + leaves[0] != 1:\n print((-1))\nelse:\n for depth in range(n):\n root[depth + 1] = min(\n 2 * root[depth] - leaves[depth + 1], sum_leaves[n] - sum_leaves[depth + 1]\n )\n if root[depth + 1] < root[depth] - leaves[depth + 1] or root[depth + 1] < 0:\n print((-1))\n break\n else:\n print((sum(root) + sum(leaves)))\n", "code_same": false, "relative_loc_diff_percent": 3.7037037037, "diff": ["+sum_leaves = [0] * (n + 1)", "+sum_leaves[0] = leaves[0]", "+for depth in range(n):", "+ sum_leaves[depth + 1] = sum_leaves[depth] + leaves[depth + 1]", "-nodes_min = [0] * (n + 1)", "-nodes_max = [0] * (n + 1)", "-nodes_min[n] = leaves[n]", "-nodes_max[n] = leaves[n]", "-for depth in range(n, 0, -1):", "- root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2", "- nodes_min[depth - 1] = leaves[depth - 1] + root_min", "- root_max = nodes_max[depth]", "- nodes_max[depth - 1] = leaves[depth - 1] + root_max", "-nodes = [0] * (n + 1)", "-nodes[0] = 1", "-if nodes[0] < nodes_min[0]:", "+root = [None] * (n + 1)", "+if n == 0:", "+ root[0] = 0", "+else:", "+ root[0] = 1", "+if root[0] + leaves[0] != 1:", "- roots = nodes[depth] - leaves[depth]", "- nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])", "- if nodes[depth + 1] < nodes_min[depth + 1]:", "+ root[depth + 1] = min(", "+ 2 * root[depth] - leaves[depth + 1], sum_leaves[n] - sum_leaves[depth + 1]", "+ )", "+ if root[depth + 1] < root[depth] - leaves[depth + 1] or root[depth + 1] < 0:", "- print((sum(nodes)))", "+ print((sum(root) + sum(leaves)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.455775662, "measured_runtime_v1": 0.2425963848, "runtime_lift": 1.8787405363, "key": ["s890279539", "s923250526"]} {"user_id": "u492605584", "problem_id": "p03164", "language": "python", "submission_id_v0": "s292196170", "submission_id_v1": "s917581247", "cpu_time_v0": 446, "cpu_time_v1": 321, "memory_v0": 119916, "memory_v1": 41964, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 28.03, "input": "N, W = list(map(int, input().split()))\n\nL = [list(map(int, input().split())) for i in range(N)]\n\nV = 0\n\nfor i in range(N):\n\n V += L[i][1]\n\n\n\ndp = [[10**9+1] * (V + 1) for i in range(N+1)]\n\ndp[0][0] = 0\n\nfor i in range(N):\n\n for j in range(V+1):\n\n if j - L[i][1] >= 0:\n\n dp[i+1][j] = min(dp[i][j], dp[i][j-L[i][1]] + L[i][0])\n\n else:\n\n dp[i+1][j] = dp[i][j]\n\nans = 0\n\nfor j in range(V+1):\n\n if W >= dp[-1][j]:\n\n ans = max(ans, j)\n\nprint(ans)", "target": "N, W = list(map(int, input().split()))\n\nL = [list(map(int, input().split())) for i in range(N)]\n\nV = 0\n\nfor i in range(N):\n\n V += L[i][1]\n\n\n\ndp = [10**9+1] * (V + 1)\n\ndp[0] = 0\n\nfor i in range(N):\n\n for j in range(V, -1, -1):\n\n dp[j] = min(dp[j], dp[j-L[i][1]] + L[i][0])\n\nans = 0\n\nfor j in range(V+1):\n\n if W >= dp[j]:\n\n ans = max(ans, j)\n\nprint(ans)", "code_v0_loc": 19, "code_v1_loc": 16, "code_v0_num_chars": 481, "code_v1_num_chars": 367, "code_v0_no_empty_lines": "N, W = list(map(int, input().split()))\nL = [list(map(int, input().split())) for i in range(N)]\nV = 0\nfor i in range(N):\n V += L[i][1]\ndp = [[10**9 + 1] * (V + 1) for i in range(N + 1)]\ndp[0][0] = 0\nfor i in range(N):\n for j in range(V + 1):\n if j - L[i][1] >= 0:\n dp[i + 1][j] = min(dp[i][j], dp[i][j - L[i][1]] + L[i][0])\n else:\n dp[i + 1][j] = dp[i][j]\nans = 0\nfor j in range(V + 1):\n if W >= dp[-1][j]:\n ans = max(ans, j)\nprint(ans)\n", "code_v1_no_empty_lines": "N, W = list(map(int, input().split()))\nL = [list(map(int, input().split())) for i in range(N)]\nV = 0\nfor i in range(N):\n V += L[i][1]\ndp = [10**9 + 1] * (V + 1)\ndp[0] = 0\nfor i in range(N):\n for j in range(V, -1, -1):\n dp[j] = min(dp[j], dp[j - L[i][1]] + L[i][0])\nans = 0\nfor j in range(V + 1):\n if W >= dp[j]:\n ans = max(ans, j)\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 15.7894736842, "diff": ["-dp = [[10**9 + 1] * (V + 1) for i in range(N + 1)]", "-dp[0][0] = 0", "+dp = [10**9 + 1] * (V + 1)", "+dp[0] = 0", "- for j in range(V + 1):", "- if j - L[i][1] >= 0:", "- dp[i + 1][j] = min(dp[i][j], dp[i][j - L[i][1]] + L[i][0])", "- else:", "- dp[i + 1][j] = dp[i][j]", "+ for j in range(V, -1, -1):", "+ dp[j] = min(dp[j], dp[j - L[i][1]] + L[i][0])", "- if W >= dp[-1][j]:", "+ if W >= dp[j]:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3010064836, "measured_runtime_v1": 0.1980076838, "runtime_lift": 1.5201757721, "key": ["s292196170", "s917581247"]} {"user_id": "u893063840", "problem_id": "p02702", "language": "python", "submission_id_v0": "s375368375", "submission_id_v1": "s846087139", "cpu_time_v0": 644, "cpu_time_v1": 545, "memory_v0": 26036, "memory_v1": 24420, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 15.37, "input": "from collections import Counter\n\n\n\ns = input()\n\nmod1 = 673\n\nmod2 = 3\n\n\n\nnum1 = 0\n\nnum2 = 0\n\nli1 = []\n\nli2 = []\n\npw1 = 10\n\npw2 = 10\n\nfor i, e in enumerate(s, 1):\n\n num1 *= 10\n\n num1 += int(e)\n\n num1 %= mod1\n\n inv = pow(pw1, mod1 - 2, mod1)\n\n li1.append(num1 * inv % mod1)\n\n\n\n num2 *= 10\n\n num2 += int(e)\n\n num2 %= mod2\n\n inv = pow(pw2, mod2 - 2, mod2)\n\n li2.append(num2 * inv % mod2)\n\n\n\n pw1 *= 10\n\n pw1 %= mod1\n\n pw2 *= 10\n\n pw2 %= mod2\n\n\n\nli = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]\n\nc = Counter(li)\n\n\n\nans = 0\n\nfor v in list(c.values()):\n\n ans += v * (v - 1) // 2\n\n\n\nprint(ans)\n", "target": "from collections import Counter\n\n\n\n\n\ndef f(mod):\n\n ret = [0]\n\n power = 1\n\n num = 0\n\n for i, e in enumerate(s, 1):\n\n num *= 10\n\n num += int(e)\n\n num %= mod\n\n\n\n power *= 10\n\n power %= mod\n\n inv = pow(power, mod - 2, mod)\n\n\n\n ret.append(num * inv % mod)\n\n\n\n return ret\n\n\n\n\n\ns = input()\n\n\n\nmod3 = f(3)\n\nmod673 = f(673)\n\n\n\nli = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]\n\n\n\nc = Counter(li)\n\nans = 0\n\nfor v in list(c.values()):\n\n ans += v * (v - 1) // 2\n\nprint(ans)\n", "code_v0_loc": 38, "code_v1_loc": 33, "code_v0_num_chars": 629, "code_v1_num_chars": 529, "code_v0_no_empty_lines": "from collections import Counter\n\ns = input()\nmod1 = 673\nmod2 = 3\nnum1 = 0\nnum2 = 0\nli1 = []\nli2 = []\npw1 = 10\npw2 = 10\nfor i, e in enumerate(s, 1):\n num1 *= 10\n num1 += int(e)\n num1 %= mod1\n inv = pow(pw1, mod1 - 2, mod1)\n li1.append(num1 * inv % mod1)\n num2 *= 10\n num2 += int(e)\n num2 %= mod2\n inv = pow(pw2, mod2 - 2, mod2)\n li2.append(num2 * inv % mod2)\n pw1 *= 10\n pw1 %= mod1\n pw2 *= 10\n pw2 %= mod2\nli = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]\nc = Counter(li)\nans = 0\nfor v in list(c.values()):\n ans += v * (v - 1) // 2\nprint(ans)\n", "code_v1_no_empty_lines": "from collections import Counter\n\n\ndef f(mod):\n ret = [0]\n power = 1\n num = 0\n for i, e in enumerate(s, 1):\n num *= 10\n num += int(e)\n num %= mod\n power *= 10\n power %= mod\n inv = pow(power, mod - 2, mod)\n ret.append(num * inv % mod)\n return ret\n\n\ns = input()\nmod3 = f(3)\nmod673 = f(673)\nli = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]\nc = Counter(li)\nans = 0\nfor v in list(c.values()):\n ans += v * (v - 1) // 2\nprint(ans)\n", "code_same": false, "relative_loc_diff_percent": 13.1578947368, "diff": ["+", "+def f(mod):", "+ ret = [0]", "+ power = 1", "+ num = 0", "+ for i, e in enumerate(s, 1):", "+ num *= 10", "+ num += int(e)", "+ num %= mod", "+ power *= 10", "+ power %= mod", "+ inv = pow(power, mod - 2, mod)", "+ ret.append(num * inv % mod)", "+ return ret", "+", "+", "-mod1 = 673", "-mod2 = 3", "-num1 = 0", "-num2 = 0", "-li1 = []", "-li2 = []", "-pw1 = 10", "-pw2 = 10", "-for i, e in enumerate(s, 1):", "- num1 *= 10", "- num1 += int(e)", "- num1 %= mod1", "- inv = pow(pw1, mod1 - 2, mod1)", "- li1.append(num1 * inv % mod1)", "- num2 *= 10", "- num2 += int(e)", "- num2 %= mod2", "- inv = pow(pw2, mod2 - 2, mod2)", "- li2.append(num2 * inv % mod2)", "- pw1 *= 10", "- pw1 %= mod1", "- pw2 *= 10", "- pw2 %= mod2", "-li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]", "+mod3 = f(3)", "+mod673 = f(673)", "+li = [10 * e673 + e3 for e3, e673 in zip(mod3, mod673)]"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4600284932, "measured_runtime_v1": 0.2683121743, "runtime_lift": 1.7145270963, "key": ["s375368375", "s846087139"]} {"user_id": "u207799478", "problem_id": "p03568", "language": "python", "submission_id_v0": "s195491532", "submission_id_v1": "s278252901", "cpu_time_v0": 90, "cpu_time_v1": 25, "memory_v0": 3832, "memory_v1": 3832, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 72.22, "input": "import math\n\nimport string\n\n\n\n\n\ndef readints():\n\n return list(map(int, input().split()))\n\n\n\n\n\ndef nCr(n, r):\n\n return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))\n\n\n\n\n\ndef has_duplicates2(seq):\n\n seen = []\n\n for item in seq:\n\n if not(item in seen):\n\n seen.append(item)\n\n return len(seq) != len(seen)\n\n\n\n\n\ndef divisor(n):\n\n divisor = []\n\n for i in range(1, n+1):\n\n if n % i == 0:\n\n divisor.append(i)\n\n return divisor\n\n\n\n\n\n# coordinates\n\ndx = [-1, -1, -1, 0, 0, 1, 1, 1]\n\ndy = [-1, 0, 1, -1, 1, -1, 0, 1]\n\n\n\nn = int(input())\n\na = readints()\n\n\n\n\n\ndef func(l):\n\n if len(l) == n:\n\n for i in range(len(l)):\n\n if l[i] % 2 == 0:\n\n return 1\n\n\n\n return 0\n\n return func(l+[(a[len(l)])])+func(l+[(a[len(l)]-1)])+func(l+[(a[len(l)]+1)])\n\n\n\n\n\nprint((func([])))\n", "target": "import math\n\nimport string\n\n\n\n\n\ndef readints():\n\n return list(map(int, input().split()))\n\n\n\n\n\ndef nCr(n, r):\n\n return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))\n\n\n\n\n\ndef has_duplicates2(seq):\n\n seen = []\n\n for item in seq:\n\n if not(item in seen):\n\n seen.append(item)\n\n return len(seq) != len(seen)\n\n\n\n\n\ndef divisor(n):\n\n divisor = []\n\n for i in range(1, n+1):\n\n if n % i == 0:\n\n divisor.append(i)\n\n return divisor\n\n\n\n\n\n# coordinates\n\ndx = [-1, -1, -1, 0, 0, 1, 1, 1]\n\ndy = [-1, 0, 1, -1, 1, -1, 0, 1]\n\n\n\nn = int(input())\n\na = readints()\n\nsum = 1\n\nfor i in range(len(a)):\n\n if a[i] % 2 == 0:\n\n sum *= 2\n\n else:\n\n sum *= 1\n\nprint((3**len(a)-sum))\n", "code_v0_loc": 47, "code_v1_loc": 41, "code_v0_num_chars": 865, "code_v1_num_chars": 739, "code_v0_no_empty_lines": "import math\nimport string\n\n\ndef readints():\n return list(map(int, input().split()))\n\n\ndef nCr(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\ndef has_duplicates2(seq):\n seen = []\n for item in seq:\n if not (item in seen):\n seen.append(item)\n return len(seq) != len(seen)\n\n\ndef divisor(n):\n divisor = []\n for i in range(1, n + 1):\n if n % i == 0:\n divisor.append(i)\n return divisor\n\n\n# coordinates\ndx = [-1, -1, -1, 0, 0, 1, 1, 1]\ndy = [-1, 0, 1, -1, 1, -1, 0, 1]\nn = int(input())\na = readints()\n\n\ndef func(l):\n if len(l) == n:\n for i in range(len(l)):\n if l[i] % 2 == 0:\n return 1\n return 0\n return (\n func(l + [(a[len(l)])])\n + func(l + [(a[len(l)] - 1)])\n + func(l + [(a[len(l)] + 1)])\n )\n\n\nprint((func([])))\n", "code_v1_no_empty_lines": "import math\nimport string\n\n\ndef readints():\n return list(map(int, input().split()))\n\n\ndef nCr(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\ndef has_duplicates2(seq):\n seen = []\n for item in seq:\n if not (item in seen):\n seen.append(item)\n return len(seq) != len(seen)\n\n\ndef divisor(n):\n divisor = []\n for i in range(1, n + 1):\n if n % i == 0:\n divisor.append(i)\n return divisor\n\n\n# coordinates\ndx = [-1, -1, -1, 0, 0, 1, 1, 1]\ndy = [-1, 0, 1, -1, 1, -1, 0, 1]\nn = int(input())\na = readints()\nsum = 1\nfor i in range(len(a)):\n if a[i] % 2 == 0:\n sum *= 2\n else:\n sum *= 1\nprint((3 ** len(a) - sum))\n", "code_same": false, "relative_loc_diff_percent": 12.7659574468, "diff": ["-", "-", "-def func(l):", "- if len(l) == n:", "- for i in range(len(l)):", "- if l[i] % 2 == 0:", "- return 1", "- return 0", "- return (", "- func(l + [(a[len(l)])])", "- + func(l + [(a[len(l)] - 1)])", "- + func(l + [(a[len(l)] + 1)])", "- )", "-", "-", "-print((func([])))", "+sum = 1", "+for i in range(len(a)):", "+ if a[i] % 2 == 0:", "+ sum *= 2", "+ else:", "+ sum *= 1", "+print((3 ** len(a) - sum))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3073070612, "measured_runtime_v1": 0.2000235903, "runtime_lift": 1.5363540904, "key": ["s195491532", "s278252901"]} {"user_id": "u312025627", "problem_id": "p03241", "language": "python", "submission_id_v0": "s848556972", "submission_id_v1": "s836748791", "cpu_time_v0": 174, "cpu_time_v1": 20, "memory_v0": 38640, "memory_v1": 3060, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 88.51, "input": "def main():\n\n N, M = (int(i) for i in input().split())\n\n\n\n def trial_division(n):\n\n divs = []\n\n for i in range(1, int(n**0.5)+1):\n\n if n % i == 0:\n\n divs.append(i)\n\n if i != n//i:\n\n divs.append(n//i)\n\n divs.sort(reverse=True)\n\n return divs\n\n divs = trial_division(M)\n\n for d in divs:\n\n if d*N <= M:\n\n return print(d)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "def main():\n\n def trial_division(n):\n\n divs = []\n\n for i in range(1, int(n**0.5)+1):\n\n if n % i == 0:\n\n divs.append(i)\n\n if i != n//i:\n\n divs.append(n//i)\n\n divs.sort(reverse=True)\n\n return divs\n\n\n\n N, M = (int(i) for i in input().split())\n\n divs = trial_division(M)\n\n for d in divs:\n\n if N*d <= M:\n\n return print(d)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 20, "code_v1_loc": 20, "code_v0_num_chars": 479, "code_v1_num_chars": 479, "code_v0_no_empty_lines": "def main():\n N, M = (int(i) for i in input().split())\n\n def trial_division(n):\n divs = []\n for i in range(1, int(n**0.5) + 1):\n if n % i == 0:\n divs.append(i)\n if i != n // i:\n divs.append(n // i)\n divs.sort(reverse=True)\n return divs\n\n divs = trial_division(M)\n for d in divs:\n if d * N <= M:\n return print(d)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n def trial_division(n):\n divs = []\n for i in range(1, int(n**0.5) + 1):\n if n % i == 0:\n divs.append(i)\n if i != n // i:\n divs.append(n // i)\n divs.sort(reverse=True)\n return divs\n\n N, M = (int(i) for i in input().split())\n divs = trial_division(M)\n for d in divs:\n if N * d <= M:\n return print(d)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- N, M = (int(i) for i in input().split())", "-", "+ N, M = (int(i) for i in input().split())", "- if d * N <= M:", "+ if N * d <= M:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3135980744, "measured_runtime_v1": 0.0063253348, "runtime_lift": 49.5780989437, "key": ["s848556972", "s836748791"]} {"user_id": "u754022296", "problem_id": "p04017", "language": "python", "submission_id_v0": "s083196734", "submission_id_v1": "s862767700", "cpu_time_v0": 1272, "cpu_time_v1": 635, "memory_v0": 90144, "memory_v1": 80288, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 50.08, "input": "import sys\n\ninput = sys.stdin.readline\n\nimport bisect\n\n\n\nn = int(input())\n\nX = list(map(int, input().split()))\n\nl = int(input())\n\nU = 17\n\ndp = [[0]*n for _ in range(U+1)]\n\nfor i, x in enumerate(X):\n\n t = bisect.bisect_left(X, x+l)\n\n dp[0][i] = bisect.bisect_right(X, x+l) - 1\n\nfor k in range(U):\n\n for i in range(n):\n\n dp[k+1][i] = dp[k][dp[k][i]]\n\ndef test(x, a, b):\n\n for i in range(U, -1, -1):\n\n if x >> i & 1:\n\n a = dp[i][a]\n\n return a >= b\n\ndef solve(a, b):\n\n if a > b:\n\n a, b = b, a\n\n ng = 0\n\n ok = n-1\n\n while ok - ng > 1:\n\n mid = (ng + ok) // 2\n\n if test(mid, a, b):\n\n ok = mid\n\n else:\n\n ng = mid\n\n print(ok)\n\nq = int(input())\n\nfor _ in range(q):\n\n a, b = list(map(int, input().split()))\n\n a -= 1\n\n b -= 1\n\n solve(a, b)", "target": "import sys\n\ninput = sys.stdin.readline\n\nimport bisect\n\n\n\nn = int(input())\n\nX = list(map(int, input().split()))\n\nl = int(input())\n\nU = 17\n\ndp = [[0]*n for _ in range(U+1)]\n\nfor i, x in enumerate(X):\n\n t = bisect.bisect_left(X, x+l)\n\n dp[0][i] = bisect.bisect_right(X, x+l) - 1\n\nfor k in range(U):\n\n for i in range(n):\n\n dp[k+1][i] = dp[k][dp[k][i]]\n\nq = int(input())\n\nfor _ in range(q):\n\n a, b = list(map(int, input().split()))\n\n a -= 1\n\n b -= 1\n\n if a > b:\n\n a, b = b, a\n\n res = 1\n\n for k in range(U, -1, -1):\n\n if dp[k][a] < b:\n\n a = dp[k][a]\n\n res += (1<> i & 1:\n a = dp[i][a]\n return a >= b\n\n\ndef solve(a, b):\n if a > b:\n a, b = b, a\n ng = 0\n ok = n - 1\n while ok - ng > 1:\n mid = (ng + ok) // 2\n if test(mid, a, b):\n ok = mid\n else:\n ng = mid\n print(ok)\n\n\nq = int(input())\nfor _ in range(q):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n solve(a, b)\n", "code_v1_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nimport bisect\n\nn = int(input())\nX = list(map(int, input().split()))\nl = int(input())\nU = 17\ndp = [[0] * n for _ in range(U + 1)]\nfor i, x in enumerate(X):\n t = bisect.bisect_left(X, x + l)\n dp[0][i] = bisect.bisect_right(X, x + l) - 1\nfor k in range(U):\n for i in range(n):\n dp[k + 1][i] = dp[k][dp[k][i]]\nq = int(input())\nfor _ in range(q):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n if a > b:\n a, b = b, a\n res = 1\n for k in range(U, -1, -1):\n if dp[k][a] < b:\n a = dp[k][a]\n res += 1 << k\n if a == b:\n break\n print(res)\n", "code_same": false, "relative_loc_diff_percent": 21.0526315789, "diff": ["-", "-", "-def test(x, a, b):", "- for i in range(U, -1, -1):", "- if x >> i & 1:", "- a = dp[i][a]", "- return a >= b", "-", "-", "-def solve(a, b):", "- if a > b:", "- a, b = b, a", "- ng = 0", "- ok = n - 1", "- while ok - ng > 1:", "- mid = (ng + ok) // 2", "- if test(mid, a, b):", "- ok = mid", "- else:", "- ng = mid", "- print(ok)", "-", "-", "- solve(a, b)", "+ if a > b:", "+ a, b = b, a", "+ res = 1", "+ for k in range(U, -1, -1):", "+ if dp[k][a] < b:", "+ a = dp[k][a]", "+ res += 1 << k", "+ if a == b:", "+ break", "+ print(res)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.33038889, "measured_runtime_v1": 0.2620919657, "runtime_lift": 1.2605838152, "key": ["s083196734", "s862767700"]} {"user_id": "u002459665", "problem_id": "p03854", "language": "python", "submission_id_v0": "s451133157", "submission_id_v1": "s498631928", "cpu_time_v0": 759, "cpu_time_v1": 146, "memory_v0": 3936, "memory_v1": 3188, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 80.76, "input": "def main():\n\n S = input()\n\n w1 = 'dream'[::-1]\n\n w2 = 'dreamer'[::-1]\n\n w3 = 'erase'[::-1]\n\n w4 = 'eraser'[::-1]\n\n # print(w1,w2,w3,w4)\n\n S = S[::-1]\n\n # print(S)\n\n\n\n # words = ['dream', 'dreamer', 'erase', 'eraser']\n\n words = [w1, w2, w3, w4]\n\n T = ''\n\n while S != T:\n\n cand = []\n\n for w in words:\n\n new_t = T + w\n\n cand.append(new_t) \n\n # print('cand', cand)\n\n ans = False\n\n for c in cand:\n\n if c == S[:len(c)]:\n\n T = c\n\n ans = True\n\n\n\n if not ans:\n\n break\n\n\n\n if S == T:\n\n print('YES')\n\n else:\n\n print(\"NO\")\n\n\n\nif __name__ == \"__main__\":\n\n main()", "target": "def main():\n\n S = input()\n\n w1 = 'dream'[::-1]\n\n w2 = 'dreamer'[::-1]\n\n w3 = 'erase'[::-1]\n\n w4 = 'eraser'[::-1]\n\n S = S[::-1]\n\n words = [w1, w2, w3, w4]\n\n\n\n flag = False\n\n i = 0\n\n while i < len(S):\n\n for w in words:\n\n if S[i:].startswith(w):\n\n i += len(w)\n\n flag = True\n\n break\n\n\n\n if not flag:\n\n print(\"NO\")\n\n exit()\n\n flag = False\n\n\n\n print(\"YES\")\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\n main()", "code_v0_loc": 35, "code_v1_loc": 29, "code_v0_num_chars": 724, "code_v1_num_chars": 528, "code_v0_no_empty_lines": "def main():\n S = input()\n w1 = \"dream\"[::-1]\n w2 = \"dreamer\"[::-1]\n w3 = \"erase\"[::-1]\n w4 = \"eraser\"[::-1]\n # print(w1,w2,w3,w4)\n S = S[::-1]\n # print(S)\n # words = ['dream', 'dreamer', 'erase', 'eraser']\n words = [w1, w2, w3, w4]\n T = \"\"\n while S != T:\n cand = []\n for w in words:\n new_t = T + w\n cand.append(new_t)\n # print('cand', cand)\n ans = False\n for c in cand:\n if c == S[: len(c)]:\n T = c\n ans = True\n if not ans:\n break\n if S == T:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "def main():\n S = input()\n w1 = \"dream\"[::-1]\n w2 = \"dreamer\"[::-1]\n w3 = \"erase\"[::-1]\n w4 = \"eraser\"[::-1]\n S = S[::-1]\n words = [w1, w2, w3, w4]\n flag = False\n i = 0\n while i < len(S):\n for w in words:\n if S[i:].startswith(w):\n i += len(w)\n flag = True\n break\n if not flag:\n print(\"NO\")\n exit()\n flag = False\n print(\"YES\")\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 17.1428571429, "diff": ["- # print(w1,w2,w3,w4)", "- # print(S)", "- # words = ['dream', 'dreamer', 'erase', 'eraser']", "- T = \"\"", "- while S != T:", "- cand = []", "+ flag = False", "+ i = 0", "+ while i < len(S):", "- new_t = T + w", "- cand.append(new_t)", "- # print('cand', cand)", "- ans = False", "- for c in cand:", "- if c == S[: len(c)]:", "- T = c", "- ans = True", "- if not ans:", "- break", "- if S == T:", "- print(\"YES\")", "- else:", "- print(\"NO\")", "+ if S[i:].startswith(w):", "+ i += len(w)", "+ flag = True", "+ break", "+ if not flag:", "+ print(\"NO\")", "+ exit()", "+ flag = False", "+ print(\"YES\")"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3388795207, "measured_runtime_v1": 0.2570693116, "runtime_lift": 1.3182418333, "key": ["s451133157", "s498631928"]} {"user_id": "u761320129", "problem_id": "p03806", "language": "python", "submission_id_v0": "s128261336", "submission_id_v1": "s895482909", "cpu_time_v0": 493, "cpu_time_v1": 263, "memory_v0": 4852, "memory_v1": 4852, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 46.65, "input": "N,MA,MB = list(map(int,input().split()))\n\nsrc = [tuple(map(int,input().split())) for i in range(N)]\n\n\n\nINF = 10**9\n\ndp = [[INF for j in range(401)] for i in range(401)]\n\ndp[0][0] = 0\n\nmaxa = maxb = 0\n\nfor a,b,c in src:\n\n for ai in range(maxa,-1,-1):\n\n for bi in range(maxb,-1,-1):\n\n dp[ai+a][bi+b] = min(dp[ai+a][bi+b], dp[ai][bi] + c)\n\n maxa += a\n\n maxb += b\n\n\n\nans = INF\n\nfor i in range(1,401):\n\n if MA*i > 400 or MB*i > 400: break\n\n ans = min(ans, dp[MA*i][MB*i])\n\nprint((-1 if ans == INF else ans))", "target": "N,MA,MB = list(map(int,input().split()))\n\nsrc = [tuple(map(int,input().split())) for i in range(N)]\n\n\n\nINF = 10**9\n\nMAX = 401\n\ndp = [[INF] * MAX for i in range(MAX)]\n\ndp[0][0] = 0\n\namax = bmax = 0\n\nfor a,b,n in src:\n\n for i in reversed(list(range(bmax+1))):\n\n for j in range(amax+1):\n\n if dp[i][j] == INF: continue\n\n dp[i+b][j+a] = min(dp[i+b][j+a], dp[i][j] + n)\n\n amax += a\n\n bmax += b\n\n\n\nans = INF\n\nfor i in range(1,MAX):\n\n if i*MA >= MAX or i*MB >= MAX: break\n\n ans = min(ans, dp[i*MB][i*MA])\n\nprint((-1 if ans == INF else ans))", "code_v0_loc": 19, "code_v1_loc": 21, "code_v0_num_chars": 527, "code_v1_num_chars": 562, "code_v0_no_empty_lines": "N, MA, MB = list(map(int, input().split()))\nsrc = [tuple(map(int, input().split())) for i in range(N)]\nINF = 10**9\ndp = [[INF for j in range(401)] for i in range(401)]\ndp[0][0] = 0\nmaxa = maxb = 0\nfor a, b, c in src:\n for ai in range(maxa, -1, -1):\n for bi in range(maxb, -1, -1):\n dp[ai + a][bi + b] = min(dp[ai + a][bi + b], dp[ai][bi] + c)\n maxa += a\n maxb += b\nans = INF\nfor i in range(1, 401):\n if MA * i > 400 or MB * i > 400:\n break\n ans = min(ans, dp[MA * i][MB * i])\nprint((-1 if ans == INF else ans))\n", "code_v1_no_empty_lines": "N, MA, MB = list(map(int, input().split()))\nsrc = [tuple(map(int, input().split())) for i in range(N)]\nINF = 10**9\nMAX = 401\ndp = [[INF] * MAX for i in range(MAX)]\ndp[0][0] = 0\namax = bmax = 0\nfor a, b, n in src:\n for i in reversed(list(range(bmax + 1))):\n for j in range(amax + 1):\n if dp[i][j] == INF:\n continue\n dp[i + b][j + a] = min(dp[i + b][j + a], dp[i][j] + n)\n amax += a\n bmax += b\nans = INF\nfor i in range(1, MAX):\n if i * MA >= MAX or i * MB >= MAX:\n break\n ans = min(ans, dp[i * MB][i * MA])\nprint((-1 if ans == INF else ans))\n", "code_same": false, "relative_loc_diff_percent": 9.5238095238, "diff": ["-dp = [[INF for j in range(401)] for i in range(401)]", "+MAX = 401", "+dp = [[INF] * MAX for i in range(MAX)]", "-maxa = maxb = 0", "-for a, b, c in src:", "- for ai in range(maxa, -1, -1):", "- for bi in range(maxb, -1, -1):", "- dp[ai + a][bi + b] = min(dp[ai + a][bi + b], dp[ai][bi] + c)", "- maxa += a", "- maxb += b", "+amax = bmax = 0", "+for a, b, n in src:", "+ for i in reversed(list(range(bmax + 1))):", "+ for j in range(amax + 1):", "+ if dp[i][j] == INF:", "+ continue", "+ dp[i + b][j + a] = min(dp[i + b][j + a], dp[i][j] + n)", "+ amax += a", "+ bmax += b", "-for i in range(1, 401):", "- if MA * i > 400 or MB * i > 400:", "+for i in range(1, MAX):", "+ if i * MA >= MAX or i * MB >= MAX:", "- ans = min(ans, dp[MA * i][MB * i])", "+ ans = min(ans, dp[i * MB][i * MA])"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4613628248, "measured_runtime_v1": 0.3376750898, "runtime_lift": 1.3662921511, "key": ["s128261336", "s895482909"]} {"user_id": "u325282913", "problem_id": "p03013", "language": "python", "submission_id_v0": "s961535130", "submission_id_v1": "s147927462", "cpu_time_v0": 230, "cpu_time_v1": 192, "memory_v0": 40940, "memory_v1": 7668, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 16.52, "input": "import sys\n\ninput = sys.stdin.readline\n\nN, M = list(map(int,input().split()))\n\nhole = [0] * (N+1)\n\nfor i in range(M):\n\n hole[int(input())] = 1\n\nif N == 1:\n\n print((1))\n\n exit()\n\nif N == 2:\n\n if hole[1] == 1:\n\n print((1))\n\n exit()\n\n if hole[1] == 0:\n\n print((2))\n\n exit()\n\nflg_one = False\n\nflg_two = False\n\nfirst = 1\n\nsecond = 2\n\nif hole[1] == 1:\n\n first = 0\n\n second = 1\n\n flg_one = True\n\nif hole[2] == 1:\n\n first = 1\n\n second = 0\n\n flg_two = True\n\nif flg_one and flg_two:\n\n print((0))\n\n exit()\n\n\n\nfor i in range(3,N):\n\n if hole[i] == 1:\n\n first = second\n\n second = 0\n\n continue\n\n tmp = first + second\n\n tmp %= 1000000007\n\n first = second\n\n second = tmp\n\ntmp = first + second\n\ntmp %= 1000000007\n\nprint(tmp)", "target": "MOD = 10**9 + 7\n\nN, M = list(map(int, input().split()))\n\nstairs = [0]*(N+1)\n\nfor _ in range(M):\n\n stairs[int(input())] = 1\n\nif N == 1:\n\n print((1))\n\n exit()\n\nans = [0]*(N+1)\n\nans[1] = 1 if stairs[1] == 0 else 0\n\nans[2] = 1 + ans[1] if stairs[2] == 0 else 0\n\nfor i in range(3,N+1):\n\n if stairs[i] == 1:\n\n ans[i] = 0\n\n continue\n\n ans[i] = (ans[i-1] + ans[i-2]) % MOD\n\nprint((ans[N]))", "code_v0_loc": 44, "code_v1_loc": 17, "code_v0_num_chars": 795, "code_v1_num_chars": 400, "code_v0_no_empty_lines": "import sys\n\ninput = sys.stdin.readline\nN, M = list(map(int, input().split()))\nhole = [0] * (N + 1)\nfor i in range(M):\n hole[int(input())] = 1\nif N == 1:\n print((1))\n exit()\nif N == 2:\n if hole[1] == 1:\n print((1))\n exit()\n if hole[1] == 0:\n print((2))\n exit()\nflg_one = False\nflg_two = False\nfirst = 1\nsecond = 2\nif hole[1] == 1:\n first = 0\n second = 1\n flg_one = True\nif hole[2] == 1:\n first = 1\n second = 0\n flg_two = True\nif flg_one and flg_two:\n print((0))\n exit()\nfor i in range(3, N):\n if hole[i] == 1:\n first = second\n second = 0\n continue\n tmp = first + second\n tmp %= 1000000007\n first = second\n second = tmp\ntmp = first + second\ntmp %= 1000000007\nprint(tmp)\n", "code_v1_no_empty_lines": "MOD = 10**9 + 7\nN, M = list(map(int, input().split()))\nstairs = [0] * (N + 1)\nfor _ in range(M):\n stairs[int(input())] = 1\nif N == 1:\n print((1))\n exit()\nans = [0] * (N + 1)\nans[1] = 1 if stairs[1] == 0 else 0\nans[2] = 1 + ans[1] if stairs[2] == 0 else 0\nfor i in range(3, N + 1):\n if stairs[i] == 1:\n ans[i] = 0\n continue\n ans[i] = (ans[i - 1] + ans[i - 2]) % MOD\nprint((ans[N]))\n", "code_same": false, "relative_loc_diff_percent": 61.3636363636, "diff": ["-import sys", "-", "-input = sys.stdin.readline", "+MOD = 10**9 + 7", "-hole = [0] * (N + 1)", "-for i in range(M):", "- hole[int(input())] = 1", "+stairs = [0] * (N + 1)", "+for _ in range(M):", "+ stairs[int(input())] = 1", "-if N == 2:", "- if hole[1] == 1:", "- print((1))", "- exit()", "- if hole[1] == 0:", "- print((2))", "- exit()", "-flg_one = False", "-flg_two = False", "-first = 1", "-second = 2", "-if hole[1] == 1:", "- first = 0", "- second = 1", "- flg_one = True", "-if hole[2] == 1:", "- first = 1", "- second = 0", "- flg_two = True", "-if flg_one and flg_two:", "- print((0))", "- exit()", "-for i in range(3, N):", "- if hole[i] == 1:", "- first = second", "- second = 0", "+ans = [0] * (N + 1)", "+ans[1] = 1 if stairs[1] == 0 else 0", "+ans[2] = 1 + ans[1] if stairs[2] == 0 else 0", "+for i in range(3, N + 1):", "+ if stairs[i] == 1:", "+ ans[i] = 0", "- tmp = first + second", "- tmp %= 1000000007", "- first = second", "- second = tmp", "-tmp = first + second", "-tmp %= 1000000007", "-print(tmp)", "+ ans[i] = (ans[i - 1] + ans[i - 2]) % MOD", "+print((ans[N]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3368466201, "measured_runtime_v1": 0.2647972648, "runtime_lift": 1.2720925207, "key": ["s961535130", "s147927462"]} {"user_id": "u164727245", "problem_id": "p02596", "language": "python", "submission_id_v0": "s121951272", "submission_id_v1": "s390007993", "cpu_time_v0": 131, "cpu_time_v1": 33, "memory_v0": 9476, "memory_v1": 9244, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 74.81, "input": "# coding: utf-8\n\n\n\n\n\ndef solve(*args: str) -> str:\n\n k = int(args[0])\n\n\n\n l = 9*(k//7 if k % 7 == 0 else k)\n\n if l % 2 == 0 or l % 5 == 0:\n\n return '-1'\n\n\n\n r = phi = l\n\n for i in range(2, int(-pow(l, 1/2))):\n\n if r % i == 0:\n\n phi = phi//i*(i-1)\n\n while r % i:\n\n r //= i\n\n\n\n a = 10 % l\n\n ret = 1\n\n while(a != 1):\n\n a = a*10 % l\n\n ret += 1\n\n if phi < ret:\n\n ret = -1\n\n break\n\n\n\n return str(ret)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n print((solve(*(open(0).read().splitlines()))))\n", "target": "# coding: utf-8\n\nfrom math import sqrt\n\n\n\n\n\ndef solve(*args: str) -> str:\n\n k = int(args[0])\n\n\n\n l = 9*(k//7 if 0 == k % 7 else k)\n\n if 0 == l % 2 or 0 == l % 5:\n\n return '-1'\n\n\n\n r = phi = l\n\n for i in range(2, int(sqrt(l)+1)):\n\n if 0 == r % i:\n\n phi = phi*(i-1)//i\n\n while 0 == r % i:\n\n r //= i\n\n if 1 < r:\n\n phi = phi*(r-1)//r\n\n\n\n D = set()\n\n for d in range(1, int(sqrt(phi)+1)):\n\n if 0 == phi % d:\n\n D.add(d)\n\n D.add(phi//d)\n\n\n\n ret = -1\n\n for m in sorted(D):\n\n if 1 == pow(10, m, l):\n\n ret = m\n\n break\n\n\n\n return str(ret)\n\n\n\n\n\nif __name__ == \"__main__\":\n\n print((solve(*(open(0).read().splitlines()))))\n", "code_v0_loc": 31, "code_v1_loc": 37, "code_v0_num_chars": 598, "code_v1_num_chars": 758, "code_v0_no_empty_lines": "# coding: utf-8\ndef solve(*args: str) -> str:\n k = int(args[0])\n l = 9 * (k // 7 if k % 7 == 0 else k)\n if l % 2 == 0 or l % 5 == 0:\n return \"-1\"\n r = phi = l\n for i in range(2, int(-pow(l, 1 / 2))):\n if r % i == 0:\n phi = phi // i * (i - 1)\n while r % i:\n r //= i\n a = 10 % l\n ret = 1\n while a != 1:\n a = a * 10 % l\n ret += 1\n if phi < ret:\n ret = -1\n break\n return str(ret)\n\n\nif __name__ == \"__main__\":\n print((solve(*(open(0).read().splitlines()))))\n", "code_v1_no_empty_lines": "# coding: utf-8\nfrom math import sqrt\n\n\ndef solve(*args: str) -> str:\n k = int(args[0])\n l = 9 * (k // 7 if 0 == k % 7 else k)\n if 0 == l % 2 or 0 == l % 5:\n return \"-1\"\n r = phi = l\n for i in range(2, int(sqrt(l) + 1)):\n if 0 == r % i:\n phi = phi * (i - 1) // i\n while 0 == r % i:\n r //= i\n if 1 < r:\n phi = phi * (r - 1) // r\n D = set()\n for d in range(1, int(sqrt(phi) + 1)):\n if 0 == phi % d:\n D.add(d)\n D.add(phi // d)\n ret = -1\n for m in sorted(D):\n if 1 == pow(10, m, l):\n ret = m\n break\n return str(ret)\n\n\nif __name__ == \"__main__\":\n print((solve(*(open(0).read().splitlines()))))\n", "code_same": false, "relative_loc_diff_percent": 16.2162162162, "diff": ["+from math import sqrt", "+", "+", "- l = 9 * (k // 7 if k % 7 == 0 else k)", "- if l % 2 == 0 or l % 5 == 0:", "+ l = 9 * (k // 7 if 0 == k % 7 else k)", "+ if 0 == l % 2 or 0 == l % 5:", "- for i in range(2, int(-pow(l, 1 / 2))):", "- if r % i == 0:", "- phi = phi // i * (i - 1)", "- while r % i:", "+ for i in range(2, int(sqrt(l) + 1)):", "+ if 0 == r % i:", "+ phi = phi * (i - 1) // i", "+ while 0 == r % i:", "- a = 10 % l", "- ret = 1", "- while a != 1:", "- a = a * 10 % l", "- ret += 1", "- if phi < ret:", "- ret = -1", "+ if 1 < r:", "+ phi = phi * (r - 1) // r", "+ D = set()", "+ for d in range(1, int(sqrt(phi) + 1)):", "+ if 0 == phi % d:", "+ D.add(d)", "+ D.add(phi // d)", "+ ret = -1", "+ for m in sorted(D):", "+ if 1 == pow(10, m, l):", "+ ret = m"], "diff_only_import_comment": false, "measured_runtime_v0": 0.4349818358, "measured_runtime_v1": 0.2757263954, "runtime_lift": 1.5775850377, "key": ["s121951272", "s390007993"]} {"user_id": "u618107373", "problem_id": "p03013", "language": "python", "submission_id_v0": "s205446737", "submission_id_v1": "s887904874", "cpu_time_v0": 450, "cpu_time_v1": 113, "memory_v0": 473344, "memory_v1": 11884, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 74.89, "input": "import sys\n\nsys.setrecursionlimit(100000)\n\n\n\ndef intinput(): return list(map(int,sys.stdin.readline().split()))\n\n\n\nfib={0:0,1:1,2:1}\n\nfor i in range(3,100003):\n\n fib[i]=fib[i-1]+fib[i-2]\n\n # fib.append(fib[i-1]+fib[i-2])\n\n\n\nn,m=intinput()\n\nmod=10**9+7\n\na=[int(sys.stdin.readline()) for _ in range(m)]\n\nif m!=0:\n\n l=[a[0]]\n\n for i in range(len(a)-1):\n\n l.append(a[i+1]-a[i]-1)\n\n l.append(n-a[-1])\n\n k=1\n\n for i in l:\n\n k=fib[i]*k%mod\n\n print((k%mod))\n\nelse:\n\n print((fib[n+1]%mod))", "target": "import sys\n\nsys.setrecursionlimit(100000)\n\n\n\ndef intinput(): return list(map(int,sys.stdin.readline().split()))\n\n\n\n\n\nn, m = intinput()\n\na = {int(sys.stdin.readline()) for _ in range(m)}\n\nmemo = [0 for x in range(n + 4)]\n\nmemo[0] = 1\n\nmod = 10 ** 9 + 7\n\nfor i in range(n):\n\n if i + 1 not in a:\n\n memo[i + 1] = (memo[i + 1] + memo[i]) % mod\n\n if i + 2 not in a:\n\n memo[i + 2] = (memo[i + 2] + memo[i]) % mod\n\nprint((memo[n]))", "code_v0_loc": 24, "code_v1_loc": 17, "code_v0_num_chars": 510, "code_v1_num_chars": 435, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(100000)\n\n\ndef intinput():\n return list(map(int, sys.stdin.readline().split()))\n\n\nfib = {0: 0, 1: 1, 2: 1}\nfor i in range(3, 100003):\n fib[i] = fib[i - 1] + fib[i - 2]\n# fib.append(fib[i-1]+fib[i-2])\nn, m = intinput()\nmod = 10**9 + 7\na = [int(sys.stdin.readline()) for _ in range(m)]\nif m != 0:\n l = [a[0]]\n for i in range(len(a) - 1):\n l.append(a[i + 1] - a[i] - 1)\n l.append(n - a[-1])\n k = 1\n for i in l:\n k = fib[i] * k % mod\n print((k % mod))\nelse:\n print((fib[n + 1] % mod))\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(100000)\n\n\ndef intinput():\n return list(map(int, sys.stdin.readline().split()))\n\n\nn, m = intinput()\na = {int(sys.stdin.readline()) for _ in range(m)}\nmemo = [0 for x in range(n + 4)]\nmemo[0] = 1\nmod = 10**9 + 7\nfor i in range(n):\n if i + 1 not in a:\n memo[i + 1] = (memo[i + 1] + memo[i]) % mod\n if i + 2 not in a:\n memo[i + 2] = (memo[i + 2] + memo[i]) % mod\nprint((memo[n]))\n", "code_same": false, "relative_loc_diff_percent": 29.1666666667, "diff": ["-fib = {0: 0, 1: 1, 2: 1}", "-for i in range(3, 100003):", "- fib[i] = fib[i - 1] + fib[i - 2]", "-# fib.append(fib[i-1]+fib[i-2])", "+a = {int(sys.stdin.readline()) for _ in range(m)}", "+memo = [0 for x in range(n + 4)]", "+memo[0] = 1", "-a = [int(sys.stdin.readline()) for _ in range(m)]", "-if m != 0:", "- l = [a[0]]", "- for i in range(len(a) - 1):", "- l.append(a[i + 1] - a[i] - 1)", "- l.append(n - a[-1])", "- k = 1", "- for i in l:", "- k = fib[i] * k % mod", "- print((k % mod))", "-else:", "- print((fib[n + 1] % mod))", "+for i in range(n):", "+ if i + 1 not in a:", "+ memo[i + 1] = (memo[i + 1] + memo[i]) % mod", "+ if i + 2 not in a:", "+ memo[i + 2] = (memo[i + 2] + memo[i]) % mod", "+print((memo[n]))"], "diff_only_import_comment": false, "measured_runtime_v0": 3.8133613999, "measured_runtime_v1": 0.2074506006, "runtime_lift": 18.3820214944, "key": ["s205446737", "s887904874"]} {"user_id": "u606045429", "problem_id": "p02850", "language": "python", "submission_id_v0": "s780367922", "submission_id_v1": "s062691036", "cpu_time_v0": 222, "cpu_time_v1": 198, "memory_v0": 25900, "memory_v1": 25900, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 10.81, "input": "\"\"\"\n\nchallenge case\n\n\n\nin:\n\n3\n\n1 3\n\n2 3\n\n\n\nout:\n\n1\n\n1\n\n1\n\n\"\"\"\n\n\n\nfrom collections import deque\n\n\n\ndef main():\n\n\tN, *AB = list(map(int, open(0).read().split()))\n\n\tB = AB[1::2]\n\n\n\n\tE = [[] for _ in range(N + 1)]\n\n\tfor a, b in zip(*[iter(AB)] * 2):\n\n\t\tE[a] += b,\n\n\n\n\tQ = deque([1])\n\n\tC = [0] * (N + 1)\n\n\twhile Q:\n\n\t\tv = Q.popleft()\n\n\t\tc = 0\n\n\t\tfor u in E[v]:\n\n\t\t\tc += 1 + (c + 1 == C[v])\n\n\t\t\tC[u] = c\n\n\t\t\tQ += u,\n\n\n\n\tprint((max(C)))\n\n\tfor b in B:\n\n\t\tprint((C[b]))\n\n\n\nmain()", "target": "\"\"\"\n\nchallenge case\n\n\n\nin:\n\n3\n\n1 3\n\n2 3\n\n\n\nout:\n\n1\n\n1\n\n1\n\n\"\"\"\n\n\n\nfrom collections import deque\n\n\n\ndef main():\n\n\tN, *AB = list(map(int, open(0).read().split()))\n\n\tB = AB[1::2]\n\n\n\n\tE = [[] for _ in range(N + 1)]\n\n\tfor a, b in zip(*[iter(AB)] * 2):\n\n\t\tE[a].append(b)\n\n\n\n\tQ = deque([1])\n\n\tC = [0] * (N + 1)\n\n\twhile Q:\n\n\t\tv = Q.popleft()\n\n\t\tc = 0\n\n\t\tfor u in E[v]:\n\n\t\t\tc += 1 + (c + 1 == C[v])\n\n\t\t\tC[u] = c\n\n\t\t\tQ.append(u)\n\n\n\n\tprint((max(C)))\n\n\tfor b in B:\n\n\t\tprint((C[b]))\n\n\n\nmain()", "code_v0_loc": 39, "code_v1_loc": 39, "code_v0_num_chars": 460, "code_v1_num_chars": 468, "code_v0_no_empty_lines": "\"\"\"\nchallenge case\nin:\n3\n1 3\n2 3\nout:\n1\n1\n1\n\"\"\"\nfrom collections import deque\n\n\ndef main():\n N, *AB = list(map(int, open(0).read().split()))\n B = AB[1::2]\n E = [[] for _ in range(N + 1)]\n for a, b in zip(*[iter(AB)] * 2):\n E[a] += (b,)\n Q = deque([1])\n C = [0] * (N + 1)\n while Q:\n v = Q.popleft()\n c = 0\n for u in E[v]:\n c += 1 + (c + 1 == C[v])\n C[u] = c\n Q += (u,)\n print((max(C)))\n for b in B:\n print((C[b]))\n\n\nmain()\n", "code_v1_no_empty_lines": "\"\"\"\nchallenge case\nin:\n3\n1 3\n2 3\nout:\n1\n1\n1\n\"\"\"\nfrom collections import deque\n\n\ndef main():\n N, *AB = list(map(int, open(0).read().split()))\n B = AB[1::2]\n E = [[] for _ in range(N + 1)]\n for a, b in zip(*[iter(AB)] * 2):\n E[a].append(b)\n Q = deque([1])\n C = [0] * (N + 1)\n while Q:\n v = Q.popleft()\n c = 0\n for u in E[v]:\n c += 1 + (c + 1 == C[v])\n C[u] = c\n Q.append(u)\n print((max(C)))\n for b in B:\n print((C[b]))\n\n\nmain()\n", "code_same": false, "relative_loc_diff_percent": 0.0, "diff": ["- E[a] += (b,)", "+ E[a].append(b)", "- Q += (u,)", "+ Q.append(u)"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2432860727, "measured_runtime_v1": 0.1842362597, "runtime_lift": 1.3205113538, "key": ["s780367922", "s062691036"]} {"user_id": "u912237403", "problem_id": "p00145", "language": "python", "submission_id_v0": "s120507501", "submission_id_v1": "s768605614", "cpu_time_v0": 160, "cpu_time_v1": 130, "memory_v0": 4524, "memory_v1": 4520, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 18.75, "input": "from functools import reduce\ndef f(a,b): return [Card[a][0], Card[b][1]]\n\nn = int(input())\n\nCard = [[] for _ in [0]*n]\n\nCost = {}\n\nfor i in range(n):\n\n Card[i] = list(map(int, input().split()))\n\n Cost[(i, i)] = 0\n\nfor i in range(1, n):\n\n for j in range(0, n-i):\n\n a = j+i\n\n Cost[(j, a)] = min([reduce(lambda a,b: a*b, f(j, k) + f(k+1, a)) + Cost[(j, k)] + Cost[(k+1, a)] for k in range(j, j+i)])\n\nprint(Cost[0, n-1])", "target": "from functools import reduce\nn = int(input())\n\nCard = [[] for _ in [0]*n]\n\nCost = {}\n\nfor i in range(n):\n\n Card[i] = list(map(int, input().split()))\n\n Cost[(i, i)] = 0\n\nfor i in range(1, n):\n\n for j in range(0, n-i):\n\n a = j+i\n\n Cost[(j, a)] = min([reduce(lambda a,b: a*b, [Card[j][0],Card[k][1],Card[k+1][0],Card[a][1]]) + Cost[(j, k)] + Cost[(k+1, a)] for k in range(j, j+i)])\n\nprint(Cost[0, n-1])", "code_v0_loc": 12, "code_v1_loc": 11, "code_v0_num_chars": 397, "code_v1_num_chars": 380, "code_v0_no_empty_lines": "from functools import reduce\n\n\ndef f(a, b):\n return [Card[a][0], Card[b][1]]\n\n\nn = int(input())\nCard = [[] for _ in [0] * n]\nCost = {}\nfor i in range(n):\n Card[i] = list(map(int, input().split()))\n Cost[(i, i)] = 0\nfor i in range(1, n):\n for j in range(0, n - i):\n a = j + i\n Cost[(j, a)] = min(\n [\n reduce(lambda a, b: a * b, f(j, k) + f(k + 1, a))\n + Cost[(j, k)]\n + Cost[(k + 1, a)]\n for k in range(j, j + i)\n ]\n )\nprint(Cost[0, n - 1])\n", "code_v1_no_empty_lines": "from functools import reduce\n\nn = int(input())\nCard = [[] for _ in [0] * n]\nCost = {}\nfor i in range(n):\n Card[i] = list(map(int, input().split()))\n Cost[(i, i)] = 0\nfor i in range(1, n):\n for j in range(0, n - i):\n a = j + i\n Cost[(j, a)] = min(\n [\n reduce(\n lambda a, b: a * b,\n [Card[j][0], Card[k][1], Card[k + 1][0], Card[a][1]],\n )\n + Cost[(j, k)]\n + Cost[(k + 1, a)]\n for k in range(j, j + i)\n ]\n )\nprint(Cost[0, n - 1])\n", "code_same": false, "relative_loc_diff_percent": 8.3333333333, "diff": ["-", "-", "-def f(a, b):", "- return [Card[a][0], Card[b][1]]", "-", "- reduce(lambda a, b: a * b, f(j, k) + f(k + 1, a))", "+ reduce(", "+ lambda a, b: a * b,", "+ [Card[j][0], Card[k][1], Card[k + 1][0], Card[a][1]],", "+ )"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2898506114, "measured_runtime_v1": 0.2096236434, "runtime_lift": 1.3827190804, "key": ["s120507501", "s768605614"]} {"user_id": "u156896646", "problem_id": "p03854", "language": "python", "submission_id_v0": "s725954700", "submission_id_v1": "s400985362", "cpu_time_v0": 76, "cpu_time_v1": 64, "memory_v0": 21348, "memory_v1": 21348, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 15.79, "input": "import sys\n\nsys.setrecursionlimit(1000000)\n\n\n\nS = input()\n\n\n\nT = ['dream', 'dreamer', 'erase', 'eraser']\n\nlenT = [len(i) for i in T]\n\n\n\ndef dayDream(pin):\n\n global isDream #;print('dayDream: ', pin, S[pin:])\n\n for i, d in enumerate(T):\n\n #print('d:', d)\n\n if S[pin:pin+lenT[i]] == d: \n\n pout = pin + lenT[i] #; print(d, pout)\n\n if pout == len(S): \n\n isDream = True #; print('YES')\n\n return \n\n else:\n\n dayDream(pout)\n\n #print('dayDream return', pin)\n\n return\n\n \n\nisDream = False\n\ndayDream(0)\n\nif isDream:\n\n print('YES')\n\nelse:\n\n print('NO')", "target": "import sys\n\nsys.setrecursionlimit(1000000)\n\n\n\nS = input()\n\n\n\nT = ['dream', 'dreamer', 'erase', 'eraser']\n\nlenT = [len(i) for i in T]\n\n\n\ndef dayDream(pin):\n\n global isGoal #;print('dayDream: ', pin, S[pin:])\n\n for i, d in enumerate(T):\n\n if isGoal:\n\n return\n\n #print('i, d:', i, d)\n\n if S[pin:pin+lenT[i]] == d: \n\n pout = pin + lenT[i] #;print(d, pout)\n\n if pout == len(S): \n\n isGoal = True #;print('YES')\n\n return \n\n else:\n\n dayDream(pout)\n\n #print('dayDream return', pin)\n\n return\n\n \n\nisGoal = False\n\ndayDream(0)\n\nif isGoal:\n\n print('YES')\n\nelse:\n\n print('NO')", "code_v0_loc": 28, "code_v1_loc": 30, "code_v0_num_chars": 694, "code_v1_num_chars": 735, "code_v0_no_empty_lines": "import sys\n\nsys.setrecursionlimit(1000000)\nS = input()\nT = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]\nlenT = [len(i) for i in T]\n\n\ndef dayDream(pin):\n global isDream # ;print('dayDream: ', pin, S[pin:])\n for i, d in enumerate(T):\n # print('d:', d)\n if S[pin : pin + lenT[i]] == d:\n pout = pin + lenT[i] # ; print(d, pout)\n if pout == len(S):\n isDream = True # ; print('YES')\n return\n else:\n dayDream(pout)\n # print('dayDream return', pin)\n return\n\n\nisDream = False\ndayDream(0)\nif isDream:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "code_v1_no_empty_lines": "import sys\n\nsys.setrecursionlimit(1000000)\nS = input()\nT = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]\nlenT = [len(i) for i in T]\n\n\ndef dayDream(pin):\n global isGoal # ;print('dayDream: ', pin, S[pin:])\n for i, d in enumerate(T):\n if isGoal:\n return\n # print('i, d:', i, d)\n if S[pin : pin + lenT[i]] == d:\n pout = pin + lenT[i] # ;print(d, pout)\n if pout == len(S):\n isGoal = True # ;print('YES')\n return\n else:\n dayDream(pout)\n # print('dayDream return', pin)\n return\n\n\nisGoal = False\ndayDream(0)\nif isGoal:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "code_same": false, "relative_loc_diff_percent": 6.6666666667, "diff": ["- global isDream # ;print('dayDream: ', pin, S[pin:])", "+ global isGoal # ;print('dayDream: ', pin, S[pin:])", "- # print('d:', d)", "+ if isGoal:", "+ return", "+ # print('i, d:', i, d)", "- pout = pin + lenT[i] # ; print(d, pout)", "+ pout = pin + lenT[i] # ;print(d, pout)", "- isDream = True # ; print('YES')", "+ isGoal = True # ;print('YES')", "-isDream = False", "+isGoal = False", "-if isDream:", "+if isGoal:"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3036904747, "measured_runtime_v1": 0.2140211895, "runtime_lift": 1.4189738666, "key": ["s725954700", "s400985362"]} {"user_id": "u256351611", "problem_id": "p02850", "language": "python", "submission_id_v0": "s596506481", "submission_id_v1": "s115492739", "cpu_time_v0": 760, "cpu_time_v1": 557, "memory_v0": 96808, "memory_v1": 30744, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 26.71, "input": "import copy\n\n\n\nn=int(input())\n\norg_set=set([i for i in range(1,10**5)])\n\nedges=[]\n\nrelations={}\n\nnodes=[]\n\nfor i in range(n-1):\n\n a,b=list(map(int,input().split(\" \")))\n\n edges.append([a,b])\n\n relations.setdefault(a,[]).append(b)\n\n nodes.append([])\n\nnodes.append([])\n\nnodes.append([])\n\n\n\nmax_color=0\n\nfor start in range(1,n+1):\n\n targets=relations.get(start,[])\n\n color=1\n\n for target in targets:\n\n if color in nodes[start]:\n\n color+=1\n\n else:\n\n pass\n\n nodes[target].append(color)\n\n if color>=max_color:\n\n max_color=color\n\n color+=1\n\n\n\nprint(max_color)\n\nfor edge in edges:\n\n print((nodes[edge[1]][0]))", "target": "n=int(input())\n\nedges=[]\n\nrelations={}\n\nnodes=[0,0]\n\nfor i in range(n-1):\n\n a,b=list(map(int,input().split(\" \")))\n\n edges.append([a,b])\n\n relations.setdefault(a,[]).append(b)\n\n nodes.append(0)\n\n\n\nmax_color=0\n\nfor start in range(1,n+1):\n\n targets=relations.get(start,[])\n\n color=1\n\n for target in targets:\n\n if color == nodes[start]:\n\n color+=1\n\n else:\n\n pass\n\n nodes[target]=color\n\n if color>=max_color:\n\n max_color=color\n\n color+=1\n\n\n\nprint(max_color)\n\nfor edge in edges:\n\n print((nodes[edge[1]]))", "code_v0_loc": 32, "code_v1_loc": 27, "code_v0_num_chars": 684, "code_v1_num_chars": 582, "code_v0_no_empty_lines": "import copy\n\nn = int(input())\norg_set = set([i for i in range(1, 10**5)])\nedges = []\nrelations = {}\nnodes = []\nfor i in range(n - 1):\n a, b = list(map(int, input().split(\" \")))\n edges.append([a, b])\n relations.setdefault(a, []).append(b)\n nodes.append([])\nnodes.append([])\nnodes.append([])\nmax_color = 0\nfor start in range(1, n + 1):\n targets = relations.get(start, [])\n color = 1\n for target in targets:\n if color in nodes[start]:\n color += 1\n else:\n pass\n nodes[target].append(color)\n if color >= max_color:\n max_color = color\n color += 1\nprint(max_color)\nfor edge in edges:\n print((nodes[edge[1]][0]))\n", "code_v1_no_empty_lines": "n = int(input())\nedges = []\nrelations = {}\nnodes = [0, 0]\nfor i in range(n - 1):\n a, b = list(map(int, input().split(\" \")))\n edges.append([a, b])\n relations.setdefault(a, []).append(b)\n nodes.append(0)\nmax_color = 0\nfor start in range(1, n + 1):\n targets = relations.get(start, [])\n color = 1\n for target in targets:\n if color == nodes[start]:\n color += 1\n else:\n pass\n nodes[target] = color\n if color >= max_color:\n max_color = color\n color += 1\nprint(max_color)\nfor edge in edges:\n print((nodes[edge[1]]))\n", "code_same": false, "relative_loc_diff_percent": 15.625, "diff": ["-import copy", "-", "-org_set = set([i for i in range(1, 10**5)])", "-nodes = []", "+nodes = [0, 0]", "- nodes.append([])", "-nodes.append([])", "-nodes.append([])", "+ nodes.append(0)", "- if color in nodes[start]:", "+ if color == nodes[start]:", "- nodes[target].append(color)", "+ nodes[target] = color", "- print((nodes[edge[1]][0]))", "+ print((nodes[edge[1]]))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.2673016732, "measured_runtime_v1": 0.1941296165, "runtime_lift": 1.3769237172, "key": ["s596506481", "s115492739"]} {"user_id": "u634079249", "problem_id": "p02881", "language": "python", "submission_id_v0": "s671057519", "submission_id_v1": "s116621872", "cpu_time_v0": 992, "cpu_time_v1": 126, "memory_v0": 3064, "memory_v1": 3064, "status_v0": "Accepted", "status_v1": "Accepted", "improvement_frac": 87.3, "input": "import sys\n\nimport os\n\nimport math\n\n\n\nii = lambda: int(sys.stdin.buffer.readline().rstrip())\n\nil = lambda: list(map(int, sys.stdin.buffer.readline().split()))\n\niln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]\n\n\n\niss = lambda: sys.stdin.buffer.readline().decode().rstrip()\n\nisn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]\n\n\n\n\n\ndef main():\n\n if os.getenv(\"LOCAL\"):\n\n sys.stdin = open(\"input.txt\", \"r\")\n\n\n\n N = ii()\n\n ret = float('inf')\n\n I = int(math.sqrt(N)) * 10\n\n for i in range(1, I):\n\n if N%i == 0:\n\n j = N//i\n\n ret = min(ret, j + i - 2)\n\n\n\n print(ret)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "target": "import sys\n\nimport os\n\n\n\nii = lambda: int(sys.stdin.buffer.readline().rstrip())\n\nil = lambda: list(map(int, sys.stdin.buffer.readline().split()))\n\niln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]\n\n\n\niss = lambda: sys.stdin.buffer.readline().decode().rstrip()\n\nisn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]\n\n\n\n\n\ndef main():\n\n if os.getenv(\"LOCAL\"):\n\n sys.stdin = open(\"input.txt\", \"r\")\n\n\n\n N = ii()\n\n m = int(N ** .5)\n\n while N % m != 0:\n\n m -= 1\n\n else:\n\n print((int(N / m + m - 2)))\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "code_v0_loc": 29, "code_v1_loc": 25, "code_v0_num_chars": 717, "code_v1_num_chars": 627, "code_v0_no_empty_lines": "import sys\nimport os\nimport math\n\nii = lambda: int(sys.stdin.buffer.readline().rstrip())\nil = lambda: list(map(int, sys.stdin.buffer.readline().split()))\niln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]\niss = lambda: sys.stdin.buffer.readline().decode().rstrip()\nisn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]\n\n\ndef main():\n if os.getenv(\"LOCAL\"):\n sys.stdin = open(\"input.txt\", \"r\")\n N = ii()\n ret = float(\"inf\")\n I = int(math.sqrt(N)) * 10\n for i in range(1, I):\n if N % i == 0:\n j = N // i\n ret = min(ret, j + i - 2)\n print(ret)\n\n\nif __name__ == \"__main__\":\n main()\n", "code_v1_no_empty_lines": "import sys\nimport os\n\nii = lambda: int(sys.stdin.buffer.readline().rstrip())\nil = lambda: list(map(int, sys.stdin.buffer.readline().split()))\niln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]\niss = lambda: sys.stdin.buffer.readline().decode().rstrip()\nisn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]\n\n\ndef main():\n if os.getenv(\"LOCAL\"):\n sys.stdin = open(\"input.txt\", \"r\")\n N = ii()\n m = int(N**0.5)\n while N % m != 0:\n m -= 1\n else:\n print((int(N / m + m - 2)))\n\n\nif __name__ == \"__main__\":\n main()\n", "code_same": false, "relative_loc_diff_percent": 13.7931034483, "diff": ["-import math", "- ret = float(\"inf\")", "- I = int(math.sqrt(N)) * 10", "- for i in range(1, I):", "- if N % i == 0:", "- j = N // i", "- ret = min(ret, j + i - 2)", "- print(ret)", "+ m = int(N**0.5)", "+ while N % m != 0:", "+ m -= 1", "+ else:", "+ print((int(N / m + m - 2)))"], "diff_only_import_comment": false, "measured_runtime_v0": 0.3067429993, "measured_runtime_v1": 0.2119246759, "runtime_lift": 1.4474152099, "key": ["s671057519", "s116621872"]}